[ML] Use try-with-resources for InputStream (elastic/x-pack-elasticsearch#2182)

Original commit: elastic/x-pack-elasticsearch@88d5e73fec
This commit is contained in:
Chris Earle 2017-08-04 13:26:35 -04:00 committed by GitHub
parent 36bad2079d
commit 87bc215b91
1 changed files with 4 additions and 3 deletions

View File

@ -24,9 +24,10 @@ public final class DomainSplitFunction {
Map<String, Object> paramsMap = new HashMap<>(); Map<String, Object> paramsMap = new HashMap<>();
Map<String, String> exact = new HashMap<>(2048); Map<String, String> exact = new HashMap<>(2048);
try {
InputStream resource = String exactResourceName = "org/elasticsearch/xpack/ml/transforms/exact.properties";
DomainSplitFunction.class.getClassLoader().getResourceAsStream("org/elasticsearch/xpack/ml/transforms/exact.properties");
try (InputStream resource = DomainSplitFunction.class.getClassLoader().getResourceAsStream(exactResourceName)) {
List<String> lines = Streams.readAllLines(resource); List<String> lines = Streams.readAllLines(resource);
for (String line : lines) { for (String line : lines) {
String[] split = line.split("="); String[] split = line.split("=");