From ab1fee874f408a740df16f55190610e1013446ac Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 26 Oct 2016 12:58:05 -0400 Subject: [PATCH] Fix FindBugs warnings in blueprint and enable enforcement Warnings fixed: - OpendaylightNamespaceHandler(line 83): "Usage of GetResource may be unsafe if class is extended". Made the class final so it can't be extended. - BlueprintContainerRestartServiceImpl(line 140): "return value of this method should be checked". Log warning if 'await' returns false. Change-Id: I1473acabd0a4126f5e5d2745292fcbff9a308462 Signed-off-by: Tom Pantelis --- opendaylight/blueprint/pom.xml | 7 +++++++ .../blueprint/BlueprintContainerRestartServiceImpl.java | 8 +++++++- .../blueprint/ext/OpendaylightNamespaceHandler.java | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/opendaylight/blueprint/pom.xml b/opendaylight/blueprint/pom.xml index 226a03774c..4ae8c6e0e0 100644 --- a/opendaylight/blueprint/pom.xml +++ b/opendaylight/blueprint/pom.xml @@ -103,6 +103,13 @@ checkstyle.violationSeverity=error + + org.codehaus.mojo + findbugs-maven-plugin + + true + + diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java index e58c956b5a..5adb4e51a6 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java @@ -68,6 +68,7 @@ import org.w3c.dom.Element; */ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintContainerRestartService { private static final Logger LOG = LoggerFactory.getLogger(BlueprintContainerRestartServiceImpl.class); + private static final int CONTAINER_CREATE_TIMEOUT_IN_MINUTES = 5; private static final String CONFIG_MODULE_NAMESPACE_PROP = "config-module-namespace"; private static final String CONFIG_MODULE_NAME_PROP = "config-module-name"; private static final String CONFIG_INSTANCE_NAME_PROP = "config-instance-name"; @@ -143,7 +144,12 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo try { - containerCreationComplete.await(5, TimeUnit.MINUTES); + if (!containerCreationComplete.await(CONTAINER_CREATE_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)) { + LOG.warn("Failed to restart all blueprint containers within {} minutes. Attempted to restart {} {} " + + "but only {} completed restart", CONTAINER_CREATE_TIMEOUT_IN_MINUTES, containerBundles.size(), + containerBundles, containerBundles.size() - containerCreationComplete.getCount()); + return; + } } catch (InterruptedException e) { LOG.debug("CountDownLatch await was interrupted - returning"); return; diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java index 976eb7b9d5..7a60b35606 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java @@ -51,7 +51,7 @@ import org.xml.sax.SAXException; * * @author Thomas Pantelis */ -public class OpendaylightNamespaceHandler implements NamespaceHandler { +public final class OpendaylightNamespaceHandler implements NamespaceHandler { public static final String NAMESPACE_1_0_0 = "http://opendaylight.org/xmlns/blueprint/v1.0.0"; static final String ROUTED_RPC_REG_CONVERTER_NAME = "org.opendaylight.blueprint.RoutedRpcRegConverter"; static final String RPC_REGISTRY_NAME = "org.opendaylight.blueprint.RpcRegistry"; -- 2.36.6