Log timeouts 08/103408/2
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 09:06:59 +0000 (10:06 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 26 Nov 2022 09:15:46 +0000 (10:15 +0100)
Sonar is complaining about TimeoutException, log them.

Change-Id: Ia3f33fb5f66b7bba71763e281172184c56b46394
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/FutureSchema.java

index 6d66ce888808b0daf7ff6c0dafb15b397e627797..03248a75bca49edc341938203f473e9a9778e9f9 100644 (file)
@@ -22,6 +22,8 @@ import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 abstract class FutureSchema implements AutoCloseable {
     private static final class Waiting extends FutureSchema {
@@ -46,15 +48,16 @@ abstract class FutureSchema implements AutoCloseable {
 
         final boolean waitForSchema() {
             try {
-                schemaPromise.get(FutureSchema.this.duration, FutureSchema.this.unit);
+                schemaPromise.get(duration, unit);
                 return true;
             } catch (final InterruptedException | ExecutionException e) {
                 throw new IllegalStateException(e);
             } catch (final TimeoutException e) {
+                LOG.trace("Wait for {} timed out", schemaPromise, e);
                 return false;
             } finally {
-                synchronized (FutureSchema.this.postponedOperations) {
-                    FutureSchema.this.postponedOperations.remove(this);
+                synchronized (postponedOperations) {
+                    postponedOperations.remove(this);
                 }
             }
         }
@@ -70,6 +73,8 @@ abstract class FutureSchema implements AutoCloseable {
         }
     }
 
+    private static final Logger LOG = LoggerFactory.getLogger(FutureSchema.class);
+
     @GuardedBy("postponedOperations")
     private final Set<FutureSchemaPredicate> postponedOperations = new LinkedHashSet<>();
     private final long duration;
@@ -78,7 +83,7 @@ abstract class FutureSchema implements AutoCloseable {
     private volatile BindingRuntimeContext runtimeContext;
 
     FutureSchema(final long time, final TimeUnit unit) {
-        this.duration = time;
+        duration = time;
         this.unit = requireNonNull(unit);
     }