kpm1985 closed pull request #1039: FLUO-1038 Use try with resources for streams
in FluoAdminImpl
URL: https://github.com/apache/fluo/pull/1039
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
index 5210cc0d..b2ee0189 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
@@ -329,11 +329,11 @@ public void updateSharedConfig() {
}
}
- try {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
CuratorFramework curator = getAppCurator();
ObserverUtil.initialize(curator, config);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
sharedProps.store(baos, "Shared java props");
CuratorUtil.putData(curator, ZookeeperPath.CONFIG_SHARED,
baos.toByteArray(),
@@ -451,13 +451,14 @@ public static SimpleConfiguration
getZookeeperConfig(FluoConfiguration config) {
try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) {
curator.start();
- ByteArrayInputStream bais =
- new
ByteArrayInputStream(curator.getData().forPath(ZookeeperPath.CONFIG_SHARED));
- Properties sharedProps = new Properties();
- sharedProps.load(bais);
+ try (ByteArrayInputStream bais =
+ new
ByteArrayInputStream(curator.getData().forPath(ZookeeperPath.CONFIG_SHARED))) {
- for (String prop : sharedProps.stringPropertyNames()) {
- zooConfig.setProperty(prop, sharedProps.getProperty(prop));
+ Properties sharedProps = new Properties();
+ sharedProps.load(bais);
+ for (String prop : sharedProps.stringPropertyNames()) {
+ zooConfig.setProperty(prop, sharedProps.getProperty(prop));
+ }
}
} catch (Exception e) {
throw new IllegalStateException(e);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services