From 9c2964ce01fa05c715499206cf3d0f610c5c334d Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 24 Oct 2016 08:06:52 +0200 Subject: Fix jvpp coverity issues #2 - synchronize AbstractFutureJvppInvoker.getRequests - handle registry & jvpp close in API usage examples Change-Id: I918bf864b8212fde04f0d9194037f1c6a810fc3f Signed-off-by: Marek Gradzki --- .../fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java | 2 +- .../io/fd/vpp/jvpp/test/ConnectionTest.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'vpp-api/java/jvpp-registry/io') diff --git a/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java b/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java index ed8b8db804d..98e140e9df6 100644 --- a/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java +++ b/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/future/AbstractFutureJVppInvoker.java @@ -51,7 +51,7 @@ public abstract class AbstractFutureJVppInvoker implements FutureJVppInvoker { this.requests = Objects.requireNonNull(requestMap, "Null requestMap"); } - protected final Map>> getRequests() { + protected synchronized final Map>> getRequests() { return this.requests; } diff --git a/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/test/ConnectionTest.java b/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/test/ConnectionTest.java index ea1d8647e56..27b4d29f866 100644 --- a/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/test/ConnectionTest.java +++ b/vpp-api/java/jvpp-registry/io/fd/vpp/jvpp/test/ConnectionTest.java @@ -27,14 +27,15 @@ public class ConnectionTest { private static void testConnect() throws Exception { System.out.println("Testing JNI connection with JVppRegistry"); - JVppRegistry registry = new JVppRegistryImpl("ConnectionTest"); - System.out.println("Successfully connected to vpp"); - - Thread.sleep(5000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); + final JVppRegistry registry = new JVppRegistryImpl("ConnectionTest"); + try { + System.out.println("Successfully connected to vpp"); + Thread.sleep(5000); + System.out.println("Disconnecting..."); + Thread.sleep(1000); + } finally { + registry.close(); + } } public static void main(String[] args) throws Exception { -- cgit 1.2.3-korg