BUG-2712: do not hold lock while updating future 86/15886/2
authorRobert Varga <rovarga@cisco.com>
Tue, 17 Feb 2015 12:47:56 +0000 (13:47 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 2 Mar 2015 07:28:17 +0000 (07:28 +0000)
SettableFuture will call any and all registrants, which could
potentially lead to AB/BA deadlocks. with ProgrammingServiceImpl. Issue
the call to set outside a synchronized block.

Change-Id: Iddb268d2157256466b597aaef78002b4f474a149
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit b1b0924b465bf92172d4b1cb18c6da330a98111f)

programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionImpl.java

index e556a83d6374abb9117af45e643330482e9e49e8..6b6ca9dce2fbccf10857bcd39d603395d77daba7 100644 (file)
@@ -182,15 +182,19 @@ final class InstructionImpl implements Instruction {
     }
 
     @Override
-    public synchronized void executionCompleted(final InstructionStatus status, final Details details) {
-        Preconditions.checkState(executionFuture != null);
+    public void executionCompleted(final InstructionStatus status, final Details details) {
+        final ExecutionResult<Details> result;
 
-        cancelTimeout();
+        synchronized (this) {
+            Preconditions.checkState(this.executionFuture != null);
+
+            cancelTimeout();
 
-        // We reuse the preconditions set down in this class
-        final ExecutionResult<Details> result = new ExecutionResult<Details>(status, details);
-        setStatus(status, details);
-        executionFuture.set(result);
+            // We reuse the preconditions set down in this class
+            result = new ExecutionResult<Details>(status, details);
+            setStatus(status, details);
+        }
+        this.executionFuture.set(result);
     }
 
     synchronized void addDependant(final InstructionImpl d) {
@@ -271,4 +275,4 @@ final class InstructionImpl implements Instruction {
         schedulingFuture.set(this);
         return executionFuture;
     }
-}
\ No newline at end of file
+}