From 25a15dea8cf159835c53186531c98dae6ddf84d0 Mon Sep 17 00:00:00 2001 From: Anthony Whitford Date: Mon, 14 Dec 2015 00:52:48 -0800 Subject: [PATCH] Issue #419 - Avoiding a duplicate CPE Index Created message and resource leak. --- .../dependencycheck/analyzer/CPEAnalyzer.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 32272f342..87d40610a 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 @@ -134,17 +134,19 @@ public class CPEAnalyzer implements Analyzer { * process. */ public void open() throws IOException, DatabaseException { - cve = new CveDB(); - cve.open(); - cpe = CpeMemoryIndex.getInstance(); - try { - LOGGER.info("Creating the CPE Index"); - final long creationStart = System.currentTimeMillis(); - cpe.open(cve); - LOGGER.info("CPE Index Created ({} ms)", System.currentTimeMillis() - creationStart); - } catch (IndexException ex) { - LOGGER.debug("IndexException", ex); - throw new DatabaseException(ex); + if (!isOpen()) { + cve = new CveDB(); + cve.open(); + cpe = CpeMemoryIndex.getInstance(); + try { + LOGGER.info("Creating the CPE Index"); + final long creationStart = System.currentTimeMillis(); + cpe.open(cve); + LOGGER.info("CPE Index Created ({} ms)", System.currentTimeMillis() - creationStart); + } catch (IndexException ex) { + LOGGER.debug("IndexException", ex); + throw new DatabaseException(ex); + } } }