United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6269739 BlockingQueue.drainTo needs to throw all unchecked exceptions that Collection.add does
JDK-6269739 : BlockingQueue.drainTo needs to throw all unchecked exceptions that Collection.add does

Details
Type:
Bug
Submit Date:
2005-05-12
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2005-09-04
Component:
core-libs
OS:
generic
Sub-Component:
java.util.concurrent
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
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

                                    

Comments
EVALUATION

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



Hardware and Software, Engineered to Work Together