From 3f32c5da887a6fddaeb678ce88d717ce66f6c7cd Mon Sep 17 00:00:00 2001 From: David Kyle Date: Wed, 8 Nov 2023 08:42:11 +0000 Subject: [PATCH] use try with resource --- .../xpack/ml/packageloader/action/ModelLoaderUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugin/ml-package-loader/src/main/java/org/elasticsearch/xpack/ml/packageloader/action/ModelLoaderUtils.java b/x-pack/plugin/ml-package-loader/src/main/java/org/elasticsearch/xpack/ml/packageloader/action/ModelLoaderUtils.java index 345b7a24af0b8..43ab090e94381 100644 --- a/x-pack/plugin/ml-package-loader/src/main/java/org/elasticsearch/xpack/ml/packageloader/action/ModelLoaderUtils.java +++ b/x-pack/plugin/ml-package-loader/src/main/java/org/elasticsearch/xpack/ml/packageloader/action/ModelLoaderUtils.java @@ -118,8 +118,7 @@ static InputStream getInputStreamFromModelRepository(URI uri) throws IOException static VocabularyParts loadVocabulary(URI uri) { if (uri.getPath().endsWith(".json")) { - try { - InputStream vocabInputStream = getInputStreamFromModelRepository(uri); + try (InputStream vocabInputStream = getInputStreamFromModelRepository(uri)) { return parseVocabParts(vocabInputStream); } catch (Exception e) { throw new ElasticsearchException("Failed to load vocabulary file", e);