diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-02-26 07:04:11 +0000 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2012-02-26 07:04:11 +0000 |
commit | 5ebd9a31feea996e3630b20dcc58f8ed5bfc1f17 (patch) | |
tree | 470a3d924cb0d47852a1228c6c22ea36fc904235 | |
parent | 89b64a86711a69e9df4babfc3eeb755fa1a8186e (diff) | |
download | jacoco-5ebd9a31feea996e3630b20dcc58f8ed5bfc1f17.tar.gz |
Sonar warnings: Fix equals() semantic.
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/runtime/ExecutionDataAccessTest.java | 13 | ||||
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/runtime/ExecutionDataAccess.java | 11 |
2 files changed, 22 insertions, 2 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/runtime/ExecutionDataAccessTest.java b/org.jacoco.core.test/src/org/jacoco/core/runtime/ExecutionDataAccessTest.java index fe75f78b..4c0eb0ed 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/runtime/ExecutionDataAccessTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/runtime/ExecutionDataAccessTest.java @@ -42,6 +42,19 @@ public class ExecutionDataAccessTest { }
@Test
+ public void testEqualsPositive() {
+ assertEquals(access, access);
+ assertEquals(access.hashCode(), access.hashCode());
+ }
+
+ @Test
+ public void testEqualsNegative() {
+ final ExecutionDataAccess other = new ExecutionDataAccess(store);
+ assertFalse(access.equals(other));
+ assertFalse(access.hashCode() == other.hashCode());
+ }
+
+ @Test
public void testGetExecutionData1() {
Object[] args = new Object[] { Long.valueOf(123), "Foo",
Integer.valueOf(3) };
diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/ExecutionDataAccess.java b/org.jacoco.core/src/org/jacoco/core/runtime/ExecutionDataAccess.java index 6d344c76..4c531f49 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/ExecutionDataAccess.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/ExecutionDataAccess.java @@ -158,8 +158,15 @@ class ExecutionDataAccess { */
@Override
public boolean equals(final Object args) {
- getExecutionData((Object[]) args);
- return false;
+ if (args instanceof Object[]) {
+ getExecutionData((Object[]) args);
+ }
+ return super.equals(args);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
}
}
|