Fix FindBugs warnings in blueprint and enable enforcement 29/47629/4
authorTom Pantelis <tpanteli@brocade.com>
Wed, 26 Oct 2016 16:58:05 +0000 (12:58 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 30 Nov 2016 15:07:20 +0000 (15:07 +0000)
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>
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 226a03774cd46497ed289d95c2f20515af7fd555..4ae8c6e0e02934950ed6b2b91a33e2d3279893db 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 e58c956b5aa4229611e98ce8f44fd0d1e90499d5..5adb4e51a60c8c3e9674bf03e244ab6da969142c 100644 (file)
@@ -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;
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";