tmf: Fix possible concurrency issue with event request IDs
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 8 Dec 2014 21:10:55 +0000 (16:10 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 10 Dec 2014 16:47:39 +0000 (11:47 -0500)
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 <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/37759
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/request/TmfEventRequest.java

index d13de6653c24c09d661d28753631bb18e455b60c..4ef3f88037448b814499e0a0cb0cd2fd62032b96 100644 (file)
@@ -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;
     }
 
This page took 0.028432 seconds and 5 git commands to generate.