X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fmdsal-trace%2Fdom-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Ftrace%2Fclosetracker%2Fimpl%2FCloseTrackedTrait.java;fp=opendaylight%2Fmd-sal%2Fmdsal-trace%2Fdom-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Ftrace%2Fclosetracker%2Fimpl%2FCloseTrackedTrait.java;h=0000000000000000000000000000000000000000;hb=2611e6a728e586ea34dd891f30a473bf54d6cbd8;hp=809cdc4f5bca8afe7e220754924a3c2f1ae04729;hpb=aaea3e9a92ae9d6fac04c4a065db4b35cbca9ed0;p=controller.git diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java deleted file mode 100644 index 809cdc4f5b..0000000000 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/closetracker/impl/CloseTrackedTrait.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 Red Hat, 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, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.trace.closetracker.impl; - -import static java.util.Objects.requireNonNull; - -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. - * - *

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 - */ -@Deprecated(forRemoval = true) -public class CloseTrackedTrait> implements CloseTracked { - - // 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. - // see also e.g. https://stackoverflow.com/a/26122232/421602 - private final @Nullable Throwable allocationContext; - private final CloseTrackedRegistry closeTrackedRegistry; - private final CloseTracked realCloseTracked; - - @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD", justification = "SpotBugs and JDT annotations") - public CloseTrackedTrait(CloseTrackedRegistry transactionChainRegistry, CloseTracked realCloseTracked) { - 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(); - } else { - this.allocationContext = null; - } - this.realCloseTracked = requireNonNull(realCloseTracked, "realCloseTracked"); - this.closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry"); - this.closeTrackedRegistry.add(this); - } - - @Override - @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS") - public StackTraceElement[] getAllocationContextStackTrace() { - return allocationContext != null ? allocationContext.getStackTrace() : null; - } - - public void removeFromTrackedRegistry() { - closeTrackedRegistry.remove(this); - } - - @Override - public CloseTracked getRealCloseTracked() { - return realCloseTracked; - } - -}