Code Review 7107516: LinkedBlockingQueue/Deque.drainTo(Collection, int) returns 'maxElements' if its value is negative

Chris Hegarty chris.hegarty at oracle.com
Wed Nov 9 17:03:47 UTC 2011


On 09/11/2011 16:44, Mike Duigou wrote:
> The change looks good.
>
> The creation of node instances could use diamond. ie.

Yes, this was my initial reaction too.

Since Doug's CVS is also built with JDK6 I guess he cannot take 
advantage of new 7 features. I just tried to keep in sync rather than 
making a special exception for our downstream copy of this code. I guess 
going forward we may have to think about how we can use newer features 
in this area, but I think Doug will have this problem too.

-Chris.

>
> Node<E>  node = new Node<E>(e);
>
> could be :
>
> Node<E>  node = new Node<>(e);
>
> Mike
>
> On Nov 9 2011, at 06:55 , Chris Hegarty wrote:
>
>>
>> According to the specification for BlockingQueue.drainTo(Collection c, int maxElements), this method should return "the number of elements transferred". However the implementation of this method for LinkedBlockingQueue and LinkedBlockingDeque when given a negative number returns the given negative number.
>>
>> Invoking drainTo(Collection, int) with a value of 0 or less should simply return 0.
>>
>> This change has been pulled from Doug Lea's CVS and I have already reviewed it. Sending to the list for further scrutiny/review.
>>
>> Webrev:
>>   http://cr.openjdk.java.net/~chegar/7107516/webrev.00/webrev/
>>
>> Thanks,
>> -Chris.
>



More information about the core-libs-dev mailing list