Fix (and suppress) some static code analysis warnings in blueprint 98/56098/4
authorMichael Vorburger <vorburger@redhat.com>
Wed, 26 Apr 2017 16:26:18 +0000 (18:26 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Tue, 20 Jun 2017 15:32:19 +0000 (15:32 +0000)
Change-Id: I39a2c07176406d469f18949b30abb3deb3c21f6c
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ActionProviderBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/SpecificReferenceListMetadata.java

index f3010a41387d21d4765b33309b9c45713270c7c1..7985c5bce00e2090016986394bc17287033b866e 100644 (file)
@@ -131,8 +131,9 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
         // restart config modules.
         final CountDownLatch containerCreationComplete = new CountDownLatch(containerBundles.size());
         ServiceRegistration<?> eventHandlerReg = registerEventHandler(forBundle.getBundleContext(), event -> {
-            LOG.debug("handleEvent {} for bundle {}", event.getTopic(), event.getProperty(EventConstants.BUNDLE));
-            if (containerBundles.contains(event.getProperty(EventConstants.BUNDLE))) {
+            final Bundle bundle = (Bundle) event.getProperty(EventConstants.BUNDLE);
+            LOG.debug("handleEvent {} for bundle {}", event.getTopic(), bundle);
+            if (containerBundles.contains(bundle)) {
                 containerCreationComplete.countDown();
             }
         });
index bbd989b633a00cd36885f2d27dabc4dd6bb36b4c..104571504e1afad816a2fa563a72b3160e2adac3 100644 (file)
@@ -77,7 +77,7 @@ public class ActionProviderBean {
 
     public void init() {
         // First resolve the interface class
-        final Class<RpcService> interfaceClass = getRpcClass(interfaceName);
+        final Class<RpcService> interfaceClass = getRpcClass();
 
         LOG.debug("{}: resolved interface {} to {}", ACTION_PROVIDER, interfaceName, interfaceClass);
 
@@ -102,7 +102,7 @@ public class ActionProviderBean {
     }
 
     @SuppressWarnings("unchecked")
-    private Class<RpcService> getRpcClass(final String interfaceName) {
+    private Class<RpcService> getRpcClass() {
         final Class<?> iface;
 
         try {
index e7152a18adc8bb791e7f69e70491c9a5f3353647..bc4ebe2a64ea9ff3bf58e71e0dcba7fc86e5e2a1 100644 (file)
@@ -156,6 +156,7 @@ public class DataStoreAppConfigMetadata extends AbstractDependentComponentFactor
     }
 
     private void readInitialAppConfig(final DataBroker dataBroker) {
+        @SuppressWarnings("resource") // it's closed in the callback
         final ReadOnlyTransaction readOnlyTx = dataBroker.newReadOnlyTransaction();
         CheckedFuture<Optional<DataObject>, ReadFailedException> future = readOnlyTx.read(
                 LogicalDatastoreType.CONFIGURATION, bindingContext.appConfigPath);
index c9aab3ba9847b87b72551fbb425f70e6b9d38c22..9a0bd29a09d6ba552e0778a82381a72cbbfcd46b 100644 (file)
@@ -141,7 +141,7 @@ class SpecificReferenceListMetadata extends AbstractDependentComponentFactoryMet
 
     private Object serviceAdded(ServiceReference<Object> reference) {
         Object service = container().getBundleContext().getService(reference);
-        Object serviceType = reference.getProperty(OpendaylightNamespaceHandler.TYPE_ATTR);
+        String serviceType = (String) reference.getProperty(OpendaylightNamespaceHandler.TYPE_ATTR);
 
         LOG.debug("{}: Service type {} added from bundle {}", logName(), serviceType,
                 reference.getBundle().getSymbolicName());
@@ -166,7 +166,7 @@ class SpecificReferenceListMetadata extends AbstractDependentComponentFactoryMet
         if (isSatisfied()) {
             restartContainer();
         } else {
-            retrievedServiceTypes.add(serviceType.toString());
+            retrievedServiceTypes.add(serviceType);
             retrievedServices.add(service);
 
             if (retrievedServiceTypes.equals(expectedServiceTypes)) {