Fix ScaleUtil warnings 55/73755/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Jul 2018 15:28:39 +0000 (17:28 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Jul 2018 15:33:23 +0000 (17:33 +0200)
Callable is a generic type, use it accordingly.

Change-Id: I5f947fc4cce9ef4244684013f5980dde439baf64
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/ScaleUtil.java

index c8929e5132741974efe851d5eeacf2edd7565825..3f275681aae80eac644e285b975ac5e383b9d952 100644 (file)
@@ -196,7 +196,7 @@ public final class ScaleUtil {
         }
     }
 
-    private static class ScaleVerifyCallable implements Callable {
+    private static class ScaleVerifyCallable implements Callable<Void> {
         private static final Logger LOG = LoggerFactory.getLogger(ScaleVerifyCallable.class);
 
         private static final String RESTCONF_URL
@@ -224,7 +224,7 @@ public final class ScaleUtil {
         }
 
         @Override
-        public Object call() throws Exception {
+        public Void call() throws Exception {
             try {
                 final Response response = asyncHttpClient.executeRequest(request).get();
 
@@ -257,9 +257,9 @@ public final class ScaleUtil {
         }
     }
 
-    private static class TimeoutGuard implements Callable {
+    private static class TimeoutGuard implements Callable<Void> {
         @Override
-        public Object call() throws Exception {
+        public Void call() throws Exception {
             resultsLog.warn("Timeout for scale test reached after: {} ..aborting", STOPWATCH);
             root.warn("Timeout for scale test reached after: {} ..aborting", STOPWATCH);
             System.exit(0);
@@ -275,25 +275,20 @@ public final class ScaleUtil {
 
         @Override
         public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
-            return super.schedule(wrapCallable(callable), delay, unit);
+            return super.schedule(new LogOnExceptionCallable<>(callable), delay, unit);
         }
 
-        private Callable wrapCallable(Callable callable) {
-            return new LogOnExceptionCallable(callable);
-        }
-
-        private static class LogOnExceptionCallable implements Callable {
-            private final Callable theCallable;
+        private static class LogOnExceptionCallable<T> implements Callable<T> {
+            private final Callable<T> theCallable;
 
-            LogOnExceptionCallable(Callable theCallable) {
+            LogOnExceptionCallable(Callable<T> theCallable) {
                 this.theCallable = theCallable;
             }
 
             @Override
-            public Object call() throws Exception {
+            public T call() throws Exception {
                 try {
-                    theCallable.call();
-                    return null;
+                    return theCallable.call();
                 } catch (Exception e) {
                     // log
                     root.warn("error in executing: " + theCallable + ". It will no longer be run!", e);