You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2010/09/01 12:52:49 UTC
[testing] Proposed fix for PriorityQueue
I see a test failure in the Java 6 branch caused by my commit to match
the RI behavior,
Index: PriorityQueue.java
===================================================================
--- PriorityQueue.java (revision 967015)
+++ PriorityQueue.java (revision 967016)
@@ -278,7 +278,7 @@
@Override
public boolean contains(Object object) {
for (int i = 0; i < size; i++) {
- if(elements[i].equals(object)){
+ if (object.equals(elements[i])) {
return true;
}
}
causes
queue.contains(null) test to fail
java.lang.NullPointerException
at java.util.PriorityQueue.contains(PriorityQueue.java:281)
at
org.apache.harmony.luni.tests.java.util.PriorityQueueTest.test_contains(PriorityQueueTest.java:734)
at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
So I'd like to patch it with the obvious fix,
Index: PriorityQueue.java
===================================================================
--- PriorityQueue.java (revision 990403)
+++ PriorityQueue.java (working copy)
@@ -277,6 +277,9 @@
*/
@Override
public boolean contains(Object object) {
+ if (object == null) {
+ return false;
+ }
for (int i = 0; i < size; i++) {
if (object.equals(elements[i])) {
return true;
I'm looking for another committers support for this during the code freeze.
Regards,
Tim
Re: [testing] Proposed fix for PriorityQueue
Posted by Mark Hindess <ma...@googlemail.com>.
In message <4C...@gmail.com>, Tim Ellison writes:
>
> I see a test failure in the Java 6 branch caused by my commit to match
> the RI behavior,
>
> Index: PriorityQueue.java
> ===================================================================
> --- PriorityQueue.java (revision 967015)
> +++ PriorityQueue.java (revision 967016)
> @@ -278,7 +278,7 @@
> @Override
> public boolean contains(Object object) {
> for (int i = 0; i < size; i++) {
> - if(elements[i].equals(object)){
> + if (object.equals(elements[i])) {
> return true;
> }
> }
>
> causes
>
> queue.contains(null) test to fail
> java.lang.NullPointerException
> at java.util.PriorityQueue.contains(PriorityQueue.java:281)
> at
> org.apache.harmony.luni.tests.java.util.PriorityQueueTest.test_contains(Prior
> ityQueueTest.java:734)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
>
>
> So I'd like to patch it with the obvious fix,
>
> Index: PriorityQueue.java
> ===================================================================
> --- PriorityQueue.java (revision 990403)
> +++ PriorityQueue.java (working copy)
> @@ -277,6 +277,9 @@
> */
> @Override
> public boolean contains(Object object) {
> + if (object == null) {
> + return false;
> + }
> for (int i = 0; i < size; i++) {
> if (object.equals(elements[i])) {
> return true;
>
> I'm looking for another committers support for this during the code freeze.
+1
-Mark.