From: Alexandre Montplaisir Date: Mon, 8 Dec 2014 21:10:55 +0000 (-0500) Subject: tmf: Fix possible concurrency issue with event request IDs X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=bc4f881c29aad1b4862ae20696155a3be3115e34;p=deliverable%2Ftracecompass.git tmf: Fix possible concurrency issue with event request IDs Protect accesses to the static field with a static lock, to make sure that all requests really have different IDs. Now that coalesced requests are put in a Set, the IDs matter. Change-Id: Iccb226aa6969c8150e0c8cc506b8c68a94e902ee Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/37759 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/request/TmfEventRequest.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/request/TmfEventRequest.java index d13de6653c..4ef3f88037 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/request/TmfEventRequest.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/request/TmfEventRequest.java @@ -154,7 +154,9 @@ public abstract class TmfEventRequest implements ITmfEventRequest { int nbRequested, ExecutionType priority) { - fRequestId = fRequestNumber++; + synchronized (this.getClass()) { + fRequestId = fRequestNumber++; + } fDataType = dataType; fIndex = index; fNbRequested = nbRequested; @@ -184,7 +186,7 @@ public abstract class TmfEventRequest implements ITmfEventRequest { /** * Resets the request counter (used for testing) */ - public static void reset() { + public static synchronized void reset() { fRequestNumber = 0; }