diff --git a/agent-module/bootstraps/bootstrap-java9/src/main/java/com/navercorp/pinpoint/bootstrap/java9/module/JarFileAnalyzer.java b/agent-module/bootstraps/bootstrap-java9/src/main/java/com/navercorp/pinpoint/bootstrap/java9/module/JarFileAnalyzer.java index 63f3972b0aa0..ec9c594cf1e9 100644 --- a/agent-module/bootstraps/bootstrap-java9/src/main/java/com/navercorp/pinpoint/bootstrap/java9/module/JarFileAnalyzer.java +++ b/agent-module/bootstraps/bootstrap-java9/src/main/java/com/navercorp/pinpoint/bootstrap/java9/module/JarFileAnalyzer.java @@ -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 serviceImplClassName = readServiceProviderConfig(jarEntry); + String serviceClassName = jarEntryName.substring(SERVICE_LOADER.length()); + return new Providers(serviceClassName, serviceImplClassName); + } + + private List readServiceProviderConfig(JarEntry jarEntry) { + try (InputStream inputStream = jarFile.getInputStream(jarEntry)) { ServiceDescriptorParser parser = new ServiceDescriptorParser(); - List 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); }