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 --- .../io/fd/vpp/jvpp/snat/test/CallbackApiTest.java | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'plugins/snat-plugin') diff --git a/plugins/snat-plugin/snat/jvpp/io/fd/vpp/jvpp/snat/test/CallbackApiTest.java b/plugins/snat-plugin/snat/jvpp/io/fd/vpp/jvpp/snat/test/CallbackApiTest.java index fd462bda7c6..e168d0560e7 100644 --- a/plugins/snat-plugin/snat/jvpp/io/fd/vpp/jvpp/snat/test/CallbackApiTest.java +++ b/plugins/snat-plugin/snat/jvpp/io/fd/vpp/jvpp/snat/test/CallbackApiTest.java @@ -48,23 +48,22 @@ public class CallbackApiTest { private static void testCallbackApi() throws Exception { System.out.println("Testing Java callback API for snat plugin"); - JVppRegistry registry = new JVppRegistryImpl("SnatCallbackApiTest"); - JVpp jvpp = new JVppSnatImpl(); + try (final JVppRegistry registry = new JVppRegistryImpl("SnatCallbackApiTest"); + final JVpp jvpp = new JVppSnatImpl()) { + registry.register(jvpp, new TestCallback()); - registry.register(jvpp, new TestCallback()); + System.out.println("Sending SnatInterfaceAddDelFeature request..."); + SnatInterfaceAddDelFeature request = new SnatInterfaceAddDelFeature(); + request.isAdd = 1; + request.isInside = 1; + request.swIfIndex = 1; + final int result = jvpp.send(request); + System.out.printf("SnatInterfaceAddDelFeature send result = %d%n", result); - System.out.println("Sending SnatInterfaceAddDelFeature request..."); - SnatInterfaceAddDelFeature request = new SnatInterfaceAddDelFeature(); - request.isAdd = 1; - request.isInside = 1; - request.swIfIndex = 1; - final int result = jvpp.send(request); - System.out.printf("SnatInterfaceAddDelFeature send result = %d%n", result); + Thread.sleep(1000); - Thread.sleep(1000); - - System.out.println("Disconnecting..."); - registry.close(); + System.out.println("Disconnecting..."); + } Thread.sleep(1000); } } -- cgit 1.2.3-korg