Merge DOMExtensibleService into DOMService
[mdsal.git] / trace / mdsal-trace-impl / src / main / java / org / opendaylight / mdsal / trace / impl / CloseTrackedTrait.java
index 94311cbcfc3f73cd3202593573e376b37e3915c8..135ad04cb7973a020d24c846908405432f08916a 100644 (file)
@@ -13,17 +13,16 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.eclipse.jdt.annotation.Nullable;
 
 /**
- * Implementation of {@link CloseTracked} which can be used as a field in
- * another class which implements {@link CloseTracked} and delegates its methods
- * to this.
+ * Implementation of {@link CloseTracked} which can be used as a field in another class which implements
+ * {@link CloseTracked} and delegates its methods to this.
  *
- * <p>This is useful if that class already has another parent class.
- * If it does not, then it's typically more convenient to just extend AbstractCloseTracked.
+ * <p>
+ * This is useful if that class already has another parent class. If it does not, then it's typically more convenient to
+ *  just extend AbstractCloseTracked.
  *
  * @author Michael Vorburger.ch
  */
 final class CloseTrackedTrait<T extends CloseTracked<T>> implements CloseTracked<T> {
-
     // NB: It's important that we keep a Throwable here, and not directly the StackTraceElement[] !
     // This is because creating a new Throwable() is a lot less expensive in terms of runtime overhead
     // than actually calling its getStackTrace(), which we can delay until we really need to.
@@ -36,19 +35,20 @@ final class CloseTrackedTrait<T extends CloseTracked<T>> implements CloseTracked
         if (transactionChainRegistry.isDebugContextEnabled()) {
             // NB: We're NOT doing the (expensive) getStackTrace() here just yet (only below)
             // TODO When we're on Java 9, then instead use the new java.lang.StackWalker API..
-            this.allocationContext = new Throwable();
+            allocationContext = new Throwable();
         } else {
-            this.allocationContext = null;
+            allocationContext = null;
         }
         this.realCloseTracked = requireNonNull(realCloseTracked, "realCloseTracked");
-        this.closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry");
-        this.closeTrackedRegistry.add(this);
+        closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry");
+        closeTrackedRegistry.add(this);
     }
 
     @Override
     @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS")
     public @Nullable StackTraceElement[] getAllocationContextStackTrace() {
-        return allocationContext != null ? allocationContext.getStackTrace() : null;
+        final var local = allocationContext;
+        return local != null ? local.getStackTrace() : null;
     }
 
     public void removeFromTrackedRegistry() {