Skip to content

Commit 409525c

Browse files
committed
fix PolicyUtils not closing stream
1 parent 9d9babf commit 409525c

File tree

1 file changed

+3
-1
lines changed
  • libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy

1 file changed

+3
-1
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ private static void validatePolicyScopes(String layerName, Policy policy, Set<St
141141
public static Policy parsePolicyIfExists(String pluginName, Path pluginRoot, boolean isExternalPlugin) throws IOException {
142142
Path policyFile = pluginRoot.resolve(POLICY_FILE_NAME);
143143
if (Files.exists(policyFile)) {
144-
return new PolicyParser(Files.newInputStream(policyFile, StandardOpenOption.READ), pluginName, isExternalPlugin).parsePolicy();
144+
try (var inputStream = Files.newInputStream(policyFile, StandardOpenOption.READ)) {
145+
return new PolicyParser(inputStream, pluginName, isExternalPlugin).parsePolicy();
146+
}
145147
}
146148
return new Policy(pluginName, List.of());
147149
}

0 commit comments

Comments
 (0)