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 5adb4e5..f3010a4 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 5813a0c..3751f71 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();
         }
     }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.