Use try-with-resources 82/57082/3
authorStephen Kitt <skitt@redhat.com>
Mon, 15 May 2017 15:56:02 +0000 (17:56 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 17 May 2017 12:12:44 +0000 (12:12 +0000)
This automatically-generated patch replaces explicit Closeable
handling with try-with-resources.

Change-Id: Ib707d30dd9730fed5dacefa60d7f61c9010e2909
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java

index 5adb4e51a60c8c3e9674bf03e244ab6da969142c..f3010a41387d21d4765b33309b9c45713270c7c1 100644 (file)
@@ -236,14 +236,13 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
             return;
         }
 
-        ConfigSubsystemFacade configFacade = configFacadeFactory.createFacade("BlueprintContainerRestartService");
-        try {
+        try (ConfigSubsystemFacade configFacade = configFacadeFactory.createFacade(
+                "BlueprintContainerRestartService")) {
             restartConfigModules(configModules, configFacade);
         } catch (ParserConfigurationException | DocumentedException | ValidationException
                 | ConflictingVersionException e) {
             LOG.error("Error restarting config modules", e);
         } finally {
-            configFacade.close();
             bundleContext.ungetService(configFacadeFactoryRef);
         }
 
index 5813a0c4e9d7946e5851cfece0093a37f5daf7de..3751f719121c70f853cdd5e0c61e1746dac1b6d6 100644 (file)
@@ -71,11 +71,8 @@ public class AbstractDataBrokerTestTest extends AbstractConcurrentDataBrokerTest
     }
 
     private boolean isTopInDataStore() throws ReadFailedException {
-        ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
-        try {
+        try (ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction()) {
             return readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).checkedGet().isPresent();
-        } finally {
-            readTx.close();
         }
     }