From dc466f1480edec15f426760b041dcdf5c004eb53 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sun, 19 Jul 2015 06:21:30 -0400 Subject: [PATCH] set objects to null after closing them Former-commit-id: 3d62a1b66741d69730e39413b8d99b670d744b50 --- .../org/owasp/dependencycheck/analyzer/CPEAnalyzer.java | 2 ++ .../dependencycheck/data/update/EngineVersionCheck.java | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java index 8b004765e..ff737c451 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java @@ -154,9 +154,11 @@ public class CPEAnalyzer implements Analyzer { public void close() { if (cpe != null) { cpe.close(); + cpe = null; } if (cve != null) { cve.close(); + cve = null; } } diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java index 1c943d9ad..81df9557b 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java @@ -97,7 +97,7 @@ public class EngineVersionCheck implements CachedWebDataSource { final boolean updateNeeded = shouldUpdate(lastChecked, now, properties, currentVersion); if (updateNeeded) { LOGGER.warn("A new version of dependency-check is available. Consider updating to version {}.", - updateToVersion); + updateToVersion); } } catch (DatabaseException ex) { LOGGER.debug("Database Exception opening databases to retrieve properties", ex); @@ -115,8 +115,8 @@ public class EngineVersionCheck implements CachedWebDataSource { * @param properties the database properties object * @param currentVersion the current version of dependency-check * @return true if a newer version of the database has been released; otherwise false - * @throws UpdateException thrown if there is an error connecting to the github documentation site or accessing the - * local database. + * @throws UpdateException thrown if there is an error connecting to the github documentation site or accessing the local + * database. */ protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties, String currentVersion) throws UpdateException { @@ -172,6 +172,7 @@ public class EngineVersionCheck implements CachedWebDataSource { if (cveDB != null) { try { cveDB.close(); + cveDB = null; } catch (Throwable ignore) { LOGGER.trace("Error closing the cveDB", ignore); }