From c36348611bb1d27e473e1501c7fcadc49a156c19 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Thu, 26 Oct 2017 19:17:57 -0400 Subject: [PATCH] updates to resolve issue #954 --- .../main/java/org/owasp/dependencycheck/Engine.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java index 8eb12f35e..04bdf6063 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java @@ -892,6 +892,8 @@ public class Engine implements FileFilter, AutoCloseable { if (remainOpen) { openDatabase(true, false); } + } catch (DatabaseException ex) { + throw new UpdateException(ex.getMessage(), ex.getCause()); } catch (H2DBLockException ex) { throw new UpdateException("Unable to obtain an exclusive lock on the H2 database to perform updates", ex); } finally { @@ -911,8 +913,10 @@ public class Engine implements FileFilter, AutoCloseable { * dependency-check-core.

*

* Opens the database connection.

+ * + * @throws DatabaseException if the database connection could not be created */ - public void openDatabase() { + public void openDatabase() throws DatabaseException { openDatabase(false, true); } @@ -928,8 +932,9 @@ public class Engine implements FileFilter, AutoCloseable { * @param readOnly whether or not the database connection should be readonly * @param lockRequired whether or not a lock needs to be acquired when * opening the database + * @throws DatabaseException if the database connection could not be created */ - public void openDatabase(boolean readOnly, boolean lockRequired) { + public void openDatabase(boolean readOnly, boolean lockRequired) throws DatabaseException { if (mode.isDatabaseRequired() && database == null) { //needed to update schema any required schema changes database = new CveDB(settings); @@ -956,9 +961,9 @@ public class Engine implements FileFilter, AutoCloseable { database = new CveDB(settings); } } catch (IOException ex) { - LOGGER.debug("Unable to open db in read only mode", ex); + throw new DatabaseException("Unable to open db in read only mode", ex); } catch (H2DBLockException ex) { - LOGGER.debug("Failed to obtain lock - unable to open db in read only mode", ex); + throw new DatabaseException("Failed to obtain lock - unable to open db in read only mode", ex); } finally { if (lock != null) { lock.release();