Close inputstream. (#4184)

Co-authored-by: kezhenxu94 <kezhenxu94@163.com>
Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
Weiyi Liu 2020-01-07 10:01:25 +08:00 committed by kezhenxu94
parent 8e9a1121cd
commit b1b1615926
1 changed files with 9 additions and 8 deletions

View File

@ -51,14 +51,15 @@ public class AgentIDDecorator implements ChannelDecorator {
Enumeration<URL> resources = AgentIDDecorator.class.getClassLoader().getResources(JarFile.MANIFEST_NAME);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
InputStream is = url.openStream();
if (is != null) {
Manifest manifest = new Manifest(is);
Attributes mainAttribs = manifest.getMainAttributes();
String projectName = mainAttribs.getValue("Implementation-Vendor-Id");
if (projectName != null) {
if ("org.apache.skywalking".equals(projectName)) {
version = mainAttribs.getValue("Implementation-Version");
try (InputStream is = url.openStream()) {
if (is != null) {
Manifest manifest = new Manifest(is);
Attributes mainAttribs = manifest.getMainAttributes();
String projectName = mainAttribs.getValue("Implementation-Vendor-Id");
if (projectName != null) {
if ("org.apache.skywalking".equals(projectName)) {
version = mainAttribs.getValue("Implementation-Version");
}
}
}
}