ensured resources are closed

This commit is contained in:
Jeremy Long
2016-11-22 06:39:50 -05:00
parent 6838b9b950
commit 316b936326

View File

@@ -280,28 +280,36 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
return false; return false;
} }
if (pomEntries != null && pomEntries.size() <= 1) { if (pomEntries != null && pomEntries.size() <= 1) {
String path = null; try {
Properties pomProperties = null; String path = null;
File pomFile = null; Properties pomProperties = null;
if (pomEntries.size() == 1) { File pomFile = null;
path = pomEntries.get(0); if (pomEntries.size() == 1) {
pomFile = extractPom(path, jar); path = pomEntries.get(0);
pomProperties = retrievePomProperties(path, jar); pomFile = extractPom(path, jar);
} else { pomProperties = retrievePomProperties(path, jar);
path = FilenameUtils.removeExtension(dependency.getActualFilePath()) + ".pom"; } else {
pomFile = new File(path); path = FilenameUtils.removeExtension(dependency.getActualFilePath()) + ".pom";
} pomFile = new File(path);
if (pomFile.isFile()) {
Model pom = PomUtils.readPom(pomFile);
if (pom != null && pomProperties != null) {
pom.processProperties(pomProperties);
} }
if (pom != null) { if (pomFile.isFile()) {
return setPomEvidence(dependency, pom, classes); Model pom = PomUtils.readPom(pomFile);
if (pom != null && pomProperties != null) {
pom.processProperties(pomProperties);
}
if (pom != null) {
return setPomEvidence(dependency, pom, classes);
}
return false;
} else {
return false;
}
} finally {
try {
jar.close();
} catch (IOException ex) {
LOGGER.trace("", ex);
} }
return false;
} else {
return false;
} }
} }