re-activate FindBugs
[openflowplugin.git] / openflowplugin-common / src / main / java / org / opendaylight / openflowplugin / common / wait / SimpleTaskRetryLooper.java
index 1bb7640eccda9f70ce1c73cdc5d0a55d00259126..d0c05c1b21b1719d66b45a51bdc0c1b11090ecbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -17,20 +17,26 @@ import org.slf4j.LoggerFactory;
  */
 public class SimpleTaskRetryLooper {
 
-    private static Logger LOG = LoggerFactory.getLogger(SimpleTaskRetryLooper.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SimpleTaskRetryLooper.class);
 
     private final long tick;
     private final int maxRetries;
 
     /**
-     * @param tick       sleep between steps in miliseconds
-     * @param maxRetries retries limit
+     * It retries the task passed to its method loopUntilNoException a number of
+     * times (maxRetries).
+     *
+     * @param tick
+     *            sleep between steps in miliseconds
+     * @param maxRetries
+     *            retries limit
      */
     public SimpleTaskRetryLooper(long tick, int maxRetries) {
         this.tick = tick;
         this.maxRetries = maxRetries;
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public <T> T loopUntilNoException(Callable<T> task) throws Exception {
         T output = null;
 
@@ -48,7 +54,8 @@ public class SimpleTaskRetryLooper {
             try {
                 Thread.sleep(tick);
             } catch (InterruptedException e) {
-                LOG.debug("interrupted: {}", e.getMessage(), e);
+                LOG.debug("interrupted", e);
+                Thread.currentThread().interrupt();
             }
         }
 
@@ -56,6 +63,7 @@ public class SimpleTaskRetryLooper {
             throw taskException;
         }
 
+        LOG.debug("looper step succeeded: {}", output);
         return output;
     }
 }