*/
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;
@GuardedBy("configTransactionLock")
private List<ModuleFactory> lastListOfFactories = Collections.emptyList();
- @GuardedBy("readableSRRegistryLock") // switched in every 2ndPC
+ // switched in every 2ndPC
+ @GuardedBy("readableSRRegistryLock")
private CloseableServiceReferenceReadableRegistry readableSRRegistry =
ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
// 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()));
/**
* {@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());
}
// 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);
}
}
// (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());
}