Skip to content

Commit 5430c98

Browse files
committed
fix SynchronizedQueue.equals
1 parent f036cd0 commit 5430c98

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/main/java/rx/internal/util/SynchronizedQueue.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,25 @@ public synchronized String toString() {
9999
}
100100

101101
@Override
102-
public synchronized boolean equals(Object o) {
103-
return list.equals(o);
102+
public int hashCode() {
103+
return list.hashCode();
104104
}
105105

106106
@Override
107-
public synchronized int hashCode() {
108-
return list.hashCode();
107+
public boolean equals(Object obj) {
108+
if (this == obj)
109+
return true;
110+
if (obj == null)
111+
return false;
112+
if (getClass() != obj.getClass())
113+
return false;
114+
SynchronizedQueue<?> other = (SynchronizedQueue<?>) obj;
115+
if (list == null) {
116+
if (other.list != null)
117+
return false;
118+
} else if (!list.equals(other.list))
119+
return false;
120+
return true;
109121
}
110122

111123
@Override
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package rx.internal.util;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.Test;
6+
7+
public class SynchronizedQueueTest {
8+
9+
@Test
10+
public void testEquals() {
11+
SynchronizedQueue<Object> q = new SynchronizedQueue<Object>();
12+
assertTrue(q.equals(q));
13+
}
14+
15+
}

0 commit comments

Comments
 (0)