X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FExtensibleBundleTracker.java;h=62215d6626f833f95e47bd4e9066567a3cd91f75;hb=refs%2Fchanges%2F73%2F46573%2F5;hp=6d29604f3d47942a6acac32546af2c81e811ef34;hpb=7a2d5cb49eab242e10233e0218ee1906c13df901;p=controller.git diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java index 6d29604f3d..62215d6626 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java @@ -8,8 +8,6 @@ package org.opendaylight.controller.config.manager.impl.osgi; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -75,27 +73,18 @@ public final class ExtensibleBundleTracker extends BundleTracker> { @Override public Future addingBundle(final Bundle bundle, final BundleEvent event) { LOG.trace("Submiting AddingBundle for bundle {} and event {} to be processed asynchronously",bundle,event); - Future future = eventExecutor.submit(new Callable() { - @Override - public T call() throws Exception { - try { - T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event); + return eventExecutor.submit(() -> { + try { + T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event); - forEachAdditionalBundle(new BundleStrategy() { - @Override - public void execute(final BundleTrackerCustomizer tracker) { - tracker.addingBundle(bundle, event); - } - }); - LOG.trace("AddingBundle for {} and event {} finished successfully",bundle,event); - return primaryTrackerRetVal; - } catch (Exception e) { - LOG.error("Failed to add bundle ",e); - throw e; - } + forEachAdditionalBundle(tracker -> tracker.addingBundle(bundle, event)); + LOG.trace("AddingBundle for {} and event {} finished successfully",bundle,event); + return primaryTrackerRetVal; + } catch (Exception e) { + LOG.error("Failed to add bundle {}", bundle, e); + throw e; } }); - return future; } @Override @@ -115,15 +104,10 @@ public final class ExtensibleBundleTracker extends BundleTracker> { try { LOG.trace("Invoking removedBundle event for {}",bundle); primaryTracker.removedBundle(bundle, event, object.get()); - forEachAdditionalBundle(new BundleStrategy() { - @Override - public void execute(final BundleTrackerCustomizer tracker) { - tracker.removedBundle(bundle, event, null); - } - }); + forEachAdditionalBundle(tracker -> tracker.removedBundle(bundle, event, null)); LOG.trace("Removed bundle event for {} finished successfully.",bundle); - } catch (InterruptedException | ExecutionException e) { - LOG.error("Addition of bundle failed, ", e); + } catch (Exception e) { + LOG.error("Failed to remove bundle {}", bundle, e); } } @@ -133,7 +117,7 @@ public final class ExtensibleBundleTracker extends BundleTracker> { } } - private static interface BundleStrategy { + private interface BundleStrategy { void execute(BundleTrackerCustomizer tracker); }