From 87bc215b9109af39dadea09fb0f91f7bd4701460 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Fri, 4 Aug 2017 13:26:35 -0400 Subject: [PATCH] [ML] Use try-with-resources for InputStream (elastic/x-pack-elasticsearch#2182) Original commit: elastic/x-pack-elasticsearch@88d5e73fec6499c5f4ffff809b219f8de4773fdc --- .../elasticsearch/xpack/ml/utils/DomainSplitFunction.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java index 94d07d27cac..293885fb87f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java @@ -24,9 +24,10 @@ public final class DomainSplitFunction { Map paramsMap = new HashMap<>(); Map exact = new HashMap<>(2048); - try { - InputStream resource = - DomainSplitFunction.class.getClassLoader().getResourceAsStream("org/elasticsearch/xpack/ml/transforms/exact.properties"); + + String exactResourceName = "org/elasticsearch/xpack/ml/transforms/exact.properties"; + + try (InputStream resource = DomainSplitFunction.class.getClassLoader().getResourceAsStream(exactResourceName)) { List lines = Streams.readAllLines(resource); for (String line : lines) { String[] split = line.split("=");