Skip to content

Commit

Permalink
[#11912] Fix missing close on Jar InputStream in Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jan 7, 2025
1 parent a36ab5a commit 7700b04
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ public Providers apply(JarEntry jarEntry) {
if (jarEntryName.indexOf('/', SERVICE_LOADER.length()) != -1) {
return null;
}
try {
InputStream inputStream = jarFile.getInputStream(jarEntry);

List<String> serviceImplClassName = readServiceProviderConfig(jarEntry);
String serviceClassName = jarEntryName.substring(SERVICE_LOADER.length());
return new Providers(serviceClassName, serviceImplClassName);
}

private List<String> readServiceProviderConfig(JarEntry jarEntry) {
try (InputStream inputStream = jarFile.getInputStream(jarEntry)) {
ServiceDescriptorParser parser = new ServiceDescriptorParser();
List<String> serviceImplClassName = parser.parse(inputStream);
String serviceClassName = jarEntryName.substring(SERVICE_LOADER.length());
return new Providers(serviceClassName, serviceImplClassName);
return parser.parse(inputStream);
} catch (IOException e) {
throw new IllegalStateException(jarFile.getName() + " File read fail ", e);
}
Expand Down

0 comments on commit 7700b04

Please # to comment.