From f429bde3e40c8ccc297b81cc343546c6b03c7ebf Mon Sep 17 00:00:00 2001 From: Geneviève Bastien Date: Tue, 1 May 2018 13:29:43 -0400 Subject: callstack: Fix callstack concurrency exceptions The CallStackDepth class used by data provider should use the object ID of the callstack in its hash code, as 2 objects will be equivalent if they refer to the same callstack, no matter its content. Also, avoid concurrency exceptions while building by synchronizing access to attribute updates Change-Id: Idb806ab30e9b6d063ecbdce2a94cb045e8404200 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/121975 Tested-by: CI Bot Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../incubator/callstack/core/instrumented/CallStackDepth.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java') diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java index fbcf8da16..2a408e0cd 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/CallStackDepth.java @@ -59,7 +59,10 @@ public class CallStackDepth { @Override public int hashCode() { - return Objects.hashCode(fCallstack, fDepth); + // Compare with the actual callstack object, as the callstack's own hash may + // change as the callstack is built. Here, we are looking for the same object, + // no matter its content + return Objects.hashCode(System.identityHashCode(fCallstack), fDepth); } @Override @@ -68,7 +71,10 @@ public class CallStackDepth { return false; } CallStackDepth csd = (CallStackDepth) obj; - return Objects.equal(fCallstack, csd.fCallstack) && (fDepth == csd.fDepth); + // Compare with the actual callstack object, as the callstack's own hash may + // change as the callstack is built. Here, we are looking for the same object, + // no matter its content + return Objects.equal(System.identityHashCode(fCallstack), System.identityHashCode(csd.fCallstack)) && (fDepth == csd.fDepth); } @Override -- cgit v1.2.3