Fix jvpp coverity issues #2

- synchronize AbstractFutureJvppInvoker.getRequests
- handle registry & jvpp close in API usage examples

Change-Id: I918bf864b8212fde04f0d9194037f1c6a810fc3f
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
This commit is contained in:
Marek Gradzki
2016-10-24 08:06:52 +02:00
committed by Damjan Marion
parent e319de0b04
commit 9c2964ce01
12 changed files with 247 additions and 274 deletions

View File

@ -51,7 +51,7 @@ public abstract class AbstractFutureJVppInvoker implements FutureJVppInvoker {
this.requests = Objects.requireNonNull(requestMap, "Null requestMap");
}
protected final Map<Integer, CompletableFuture<? extends JVppReply<?>>> getRequests() {
protected synchronized final Map<Integer, CompletableFuture<? extends JVppReply<?>>> getRequests() {
return this.requests;
}

View File

@ -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 {