Fix FindBugs warnings in blueprint and enable enforcement 91/51191/1
authorTom Pantelis <tpanteli@brocade.com>
Wed, 26 Oct 2016 16:58:05 +0000 (12:58 -0400)
committerRobert Varga <rovarga@cisco.com>
Mon, 30 Jan 2017 16:04:31 +0000 (17:04 +0100)
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 <tpanteli@brocade.com>
(cherry picked from commit ab1fee874f408a740df16f55190610e1013446ac)

opendaylight/blueprint/pom.xml
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java

index acc31fd588b52eadfb578de451afc659d12577b6..3bb1e3e3640fde0595575c787608ce62605746fe 100644 (file)
           <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <configuration>
+          <failOnError>true</failOnError>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 
index 6a464b75d03533eea7a992e45439d8771af2df92..5a353e1f771b5f448ad8efc0e6f32c6a1241e47a 100644 (file)
@@ -62,6 +62,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";
@@ -136,7 +137,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;
index 976eb7b9d5c1912c28b72720b822db3bbb51f45a..7a60b356068378d9ee87c2605a876fc1981e31a3 100644 (file)
@@ -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";