BUG-2712: do not hold lock while updating future 11/15411/2
authorRobert Varga <rovarga@cisco.com>
Tue, 17 Feb 2015 12:47:56 +0000 (13:47 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 23 Feb 2015 09:12:50 +0000 (09:12 +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>
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionImpl.java

index 2929c82e72f0b650dd865639bf447358c70dc5c4..2b39ef590f330799c29edafb94b415674169826b 100644 (file)
@@ -180,14 +180,19 @@ final class InstructionImpl implements Instruction {
     }
 
     @Override
-    public synchronized void executionCompleted(final InstructionStatus status, final Details details) {
-        Preconditions.checkState(this.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
+            result = new ExecutionResult<Details>(status, details);
+            setStatus(status, details);
+        }
 
-        // We reuse the preconditions set down in this class
-        final ExecutionResult<Details> result = new ExecutionResult<Details>(status, details);
-        setStatus(status, details);
         this.executionFuture.set(result);
     }