From a0d14235087d6b2c3cac747ca26c42b15d902dcd Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 15 May 2017 17:56:02 +0200 Subject: [PATCH] Use try-with-resources This automatically-generated patch replaces explicit Closeable handling with try-with-resources. Change-Id: Ib707d30dd9730fed5dacefa60d7f61c9010e2909 Signed-off-by: Stephen Kitt --- .../blueprint/BlueprintContainerRestartServiceImpl.java | 5 ++--- .../sal/binding/test/tests/AbstractDataBrokerTestTest.java | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java index 5adb4e51a6..f3010a4138 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java @@ -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); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java index 5813a0c4e9..3751f71912 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java @@ -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(); } } -- 2.36.6