Code Review 7107516: LinkedBlockingQueue/Deque.drainTo(Collection, int) returns 'maxElements' if its value is negative
Chris Hegarty
chris.hegarty at oracle.com
Thu Nov 10 09:46:18 UTC 2011
On 10/11/2011 05:34, David Holmes wrote:
> On 10/11/2011 3:03 AM, Chris Hegarty wrote:
>> 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.
>
> Good point - I was going to make the same comment as Mike. I assume this
> change was to remove a warning.
Yes, sorry I forgot to mention this in the original mail. I just noticed
these warnings when rebuilding and though it best to drag in these
simple changes to fix them.
> Changes look good to me.
Thanks David,
-Chris.
>
> David
> -----
>
>> -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