[concurrency-interest] Exception throw but not speficied in the method contract of its interface

David Holmes dholmes@dltech.com.au
Mon, 11 Oct 2004 12:06:41 +1000

> the method add(Object) of class AbstractQueue can throw an
> IllegalStateException that is not specified in the contract of its
> interface Collection.  Is-it normal?

I should also point out that AbstractQueue was written to support the
concrete queue implementations in JDK 5.0, which includes the BlockingQueue
implementations. But as the docs say, as long as offer() succeeds then add()
will succeed too - so a subclass that will never cause offer() to fail will
never generate the IllegalStateException - and so that subclass can, and
should, override add() to document this and just invoke super.add as its

David Holmes