flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trohrm...@apache.org
Subject [13/50] [abbrv] flink git commit: [FLINK-4595] Close FileOutputStream in ParameterTool
Date Thu, 08 Sep 2016 15:28:35 GMT
[FLINK-4595] Close FileOutputStream in ParameterTool

This closes #2478


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/920cda40
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/920cda40
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/920cda40

Branch: refs/heads/flip-6
Commit: 920cda408f61a27f0b1731325b62bf141dd4b530
Parents: 7e07bde
Author: Alexander Pivovarov <apivovarov@gmail.com>
Authored: Wed Sep 7 14:11:06 2016 -0700
Committer: zentol <chesnay@apache.org>
Committed: Thu Sep 8 12:04:26 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/flink/api/java/utils/ParameterTool.java     | 5 ++++-
 .../java/org/apache/flink/api/java/utils/ParameterToolTest.java | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/920cda40/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java b/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java
index 46c7387..38ae6df 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java
@@ -31,6 +31,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -523,7 +524,9 @@ public class ParameterTool extends ExecutionConfig.GlobalJobParameters
implement
 		}
 		Properties defaultProps = new Properties();
 		defaultProps.putAll(this.defaultData);
-		defaultProps.store(new FileOutputStream(file), "Default file created by Flink's ParameterUtil.createPropertiesFile()");
+		try (final OutputStream out = new FileOutputStream(file)) {
+			defaultProps.store(out, "Default file created by Flink's ParameterUtil.createPropertiesFile()");
+		}
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/flink/blob/920cda40/flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
b/flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
index a070473..09a7781 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
@@ -29,6 +29,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Map;
 import java.util.Properties;
 
@@ -118,7 +119,9 @@ public class ParameterToolTest {
 		Properties props = new Properties();
 		props.setProperty("input", "myInput");
 		props.setProperty("expectedCount", "15");
-		props.store(new FileOutputStream(propertiesFile), "Test properties");
+		try (final OutputStream out = new FileOutputStream(propertiesFile)) {
+			props.store(out, "Test properties");
+		}
 		ParameterTool parameter = ParameterTool.fromPropertiesFile(propertiesFile.getAbsolutePath());
 		Assert.assertEquals(2, parameter.getNumberOfParameters());
 		validate(parameter);


Mime
View raw message