JDK-6269739 : BlockingQueue.drainTo needs to throw all unchecked exceptions that Collection.add does
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-12
  • Updated: 2010-04-02
  • Resolved: 2005-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
6 b51Fixed
The spec for BlockingQueue.java:

     * Removes all available elements from this queue and adds them
     * into the given collection.  This operation may be more
     * efficient than repeatedly polling this queue.  A failure
     * encountered while attempting to <tt>add</tt> elements to
     * collection <tt>c</tt> may result in elements being in neither,
     * either or both collections when the associated exception is
     * thrown. Attempts to drain a queue to itself result in
     * <tt>IllegalArgumentException</tt>. Further, the behavior of
     * this operation is undefined if the specified collection is
     * modified while the operation is in progress.
     * @param c the collection to transfer elements into
     * @return the number of elements transferred.
     * @throws NullPointerException if c is null
     * @throws IllegalArgumentException if c is this queue
    int drainTo(Collection<? super E> c);
is incomplete because this method has to be able to work with any collection,
and has to use something like Collection.add to add elements to it, and thus
any of the exceptions thrown by that, like UnsupportedOperationException
and ClassCastException, must in turn be spec'ed to be thrown by 
BlockingQueue.drainTo (both variants).  Similarly with all extending interfaces
and implementing classes.
###@###.### 2005-05-12 23:07:32 GMT

EVALUATION Will be fixed as part of the jsr166x project. ###@###.### 2005-05-12 23:09:00 GMT