This is an automated email from the ASF dual-hosted git repository. kfujino pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 2336406 Throw SQLException instead of NullpointerException when failing to connect to the database 2336406 is described below commit 2336406ef98ee096e81b64e656dcbf9e0e5a9b10 Author: KeiichiFujino <kfuj...@apache.org> AuthorDate: Thu Sep 24 22:07:53 2020 +0900 Throw SQLException instead of NullpointerException when failing to connect to the database --- java/org/apache/catalina/session/JDBCStore.java | 3 +++ java/org/apache/catalina/session/LocalStrings.properties | 1 + webapps/docs/changelog.xml | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/java/org/apache/catalina/session/JDBCStore.java b/java/org/apache/catalina/session/JDBCStore.java index 78f5e11..6e16d59 100644 --- a/java/org/apache/catalina/session/JDBCStore.java +++ b/java/org/apache/catalina/session/JDBCStore.java @@ -935,6 +935,9 @@ public class JDBCStore extends StoreBase { if (connectionPassword != null) props.put("password", connectionPassword); dbConnection = driver.connect(connectionURL, props); + if (dbConnection == null) { + throw new SQLException(sm.getString(getStoreName() + ".connectError", connectionURL)); + } dbConnection.setAutoCommit(true); return dbConnection; diff --git a/java/org/apache/catalina/session/LocalStrings.properties b/java/org/apache/catalina/session/LocalStrings.properties index 127cd43..dae4f68 100644 --- a/java/org/apache/catalina/session/LocalStrings.properties +++ b/java/org/apache/catalina/session/LocalStrings.properties @@ -25,6 +25,7 @@ JDBCStore.missingDataSourceName=No valid JNDI name was given. JDBCStore.removing=Removing Session [{0}] at database [{1}] JDBCStore.saving=Saving Session [{0}] to database [{1}] JDBCStore.wrongDataSource=Cannot open JNDI DataSource [{0}] +JDBCStore.connectError=Cannot connect to database [{0}] fileStore.createFailed=Unable to create directory [{0}] for the storage of session data fileStore.deleteFailed=Unable to delete file [{0}] which is preventing the creation of the session storage location diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index cdc6c96..1c0d118 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -62,6 +62,11 @@ <bug>64715</bug>: Add PasswordValidationCallback to the JASPIC implementation. Patch provided by Robert Rodewald. (markt) </fix> + <fix> + Throw <code>SQLException</code> instead of + <code>NullpointerException</code> when failing to connect to the + database. (kfujino) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org