Fix coverity issues 47/4447/3
authorMarek Gradzki <mgradzki@cisco.com>
Wed, 21 Dec 2016 13:29:01 +0000 (14:29 +0100)
committerDamjan Marion <dmarion.lists@gmail.com>
Wed, 21 Dec 2016 17:50:03 +0000 (17:50 +0000)
Change-Id: I7707a42321df2c73e5414926d4000f8672ecfaf3
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/JVppRegistryImpl.java
vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java

index 8e10140..98ef1c1 100644 (file)
@@ -108,11 +108,11 @@ public final class JVppRegistryImpl implements JVppRegistry, ControlPingCallback
         final ControlPingCallback callback;
         synchronized (pingCalls) {
             callback = pingCalls.remove(reply.context);
-        }
-        if (callback == null) {
-            LOG.log(Level.WARNING, "No callback was registered for reply context=" + reply.context + " Contexts waiting="
+            if (callback == null) {
+                LOG.log(Level.WARNING, "No callback was registered for reply context=" + reply.context + " Contexts waiting="
                     + pingCalls.keySet());
-            return;
+                return;
+            }
         }
         // pass the reply to the callback registered by the ping caller
         callback.onControlPingReply(reply);
index 98e140e..e7df528 100644 (file)
@@ -51,8 +51,10 @@ public abstract class AbstractFutureJVppInvoker implements FutureJVppInvoker {
         this.requests = Objects.requireNonNull(requestMap, "Null requestMap");
     }
 
-    protected synchronized final Map<Integer, CompletableFuture<? extends JVppReply<?>>> getRequests() {
-        return this.requests;
+    protected final Map<Integer, CompletableFuture<? extends JVppReply<?>>> getRequests() {
+        synchronized (requests) {
+            return requests;
+        }
     }
 
     // TODO use Optional in Future, java8