X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2FConfigRegistryImpl.java;h=763ed66cb10d947f4ef5aa95d4a6178acf8d009e;hp=b58d2afd24b095dbecb0e2a3681cd216a49758ce;hb=refs%2Fchanges%2F73%2F46573%2F5;hpb=660c3e22ca97bc613ea6f6288503620bba6fb233 diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java index b58d2afd24..763ed66cb1 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.config.manager.impl; +import com.google.common.base.Throwables; import com.google.common.collect.Maps; import java.util.ArrayList; import java.util.Collection; @@ -113,7 +114,8 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe @GuardedBy("configTransactionLock") private List lastListOfFactories = Collections.emptyList(); - @GuardedBy("readableSRRegistryLock") // switched in every 2ndPC + // switched in every 2ndPC + @GuardedBy("readableSRRegistryLock") private CloseableServiceReferenceReadableRegistry readableSRRegistry = ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(); @@ -207,7 +209,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe // add all factories that disappeared from SR but are still committed for (ModuleInternalInfo moduleInternalInfo : currentConfig.getEntries()) { String name = moduleInternalInfo.getModuleFactory().getImplementationName(); - if (allCurrentFactories.containsKey(name) == false) { + if (!allCurrentFactories.containsKey(name)) { LOG.trace("Factory {} not found in SR, using reference from previous commit", name); allCurrentFactories.put(name, Maps.immutableEntry(moduleInternalInfo.getModuleFactory(), moduleInternalInfo.getBundleContext())); @@ -237,11 +239,12 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe /** * {@inheritDoc} + * @throws ConflictingVersionException */ @Override public CommitStatus commitConfig(ObjectName transactionControllerON) - throws ConflictingVersionException, ValidationException { - if(transactionControllerON == NOOP_TX_NAME || closed.get()) { + throws ValidationException, ConflictingVersionException { + if(NOOP_TX_NAME.equals(transactionControllerON) || closed.get()) { return new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); } @@ -283,15 +286,12 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe // non recoverable from here: try { return secondPhaseCommit(configTransactionController, commitInfo, configTransactionControllerEntry.getValue()); - } catch (Error | RuntimeException t) { // some libs throw Errors: e.g. + // some libs throw Errors: e.g. // javax.xml.ws.spi.FactoryFinder$ConfigurationError + } catch (Throwable t) { isHealthy = false; LOG.error("Configuration Transaction failed on 2PC, server is unhealthy", t); - if (t instanceof RuntimeException) { - throw (RuntimeException) t; - } else { - throw (Error) t; - } + throw Throwables.propagate(t); } } @@ -303,10 +303,11 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe // (hopefully) runtime beans for (DestroyedModule toBeDestroyed : commitInfo .getDestroyedFromPreviousTransactions()) { - toBeDestroyed.close(); // closes instance (which should close + // closes instance (which should close // runtime jmx registrator), // also closes osgi registration and ModuleJMXRegistrator // registration + toBeDestroyed.close(); currentConfig.remove(toBeDestroyed.getIdentifier()); }