You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/08/08 04:41:59 UTC

[commons-dbcp] branch master updated: [DBCP-555] NPE when creating a SQLExceptionList with a null list.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f30edc  [DBCP-555] NPE when creating a SQLExceptionList with a null list.
0f30edc is described below

commit 0f30edc467a2ba03e7f2786e1088df624e0c3cf0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 8 00:41:54 2019 -0400

    [DBCP-555] NPE when creating a SQLExceptionList with a null list.
---
 src/changes/changes.xml                                          | 6 ++++++
 src/main/java/org/apache/commons/dbcp2/SQLExceptionList.java     | 5 +++--
 src/test/java/org/apache/commons/dbcp2/TestSQLExceptionList.java | 7 +++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b367994..276ce01 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,12 @@ The <action> type attribute can be add,update,fix,remove.
      -->
 
   <body>
+    <release version="2.7.1" date="2019-MM-DD" description="This is a minor release, including bug fixes and enhancements.">
+      <!-- fix -->
+      <action dev="ggregory" type="fix" issue="DBCP-555" due-to="Gary Gregory">
+        NPE when creating a SQLExceptionList with a null list.
+      </action>
+    </release>
     <release version="2.7.0" date="2019-07-31" description="This is a minor release, including bug fixes and enhancements.">
       <!-- add -->
       <action dev="jleroux" type="add" issue="DBCP-539" due-to="Jacques Le Roux">
diff --git a/src/main/java/org/apache/commons/dbcp2/SQLExceptionList.java b/src/main/java/org/apache/commons/dbcp2/SQLExceptionList.java
index b9022ae..e903608 100644
--- a/src/main/java/org/apache/commons/dbcp2/SQLExceptionList.java
+++ b/src/main/java/org/apache/commons/dbcp2/SQLExceptionList.java
@@ -40,13 +40,14 @@ public class SQLExceptionList extends SQLException {
      * @param causeList a list of cause exceptions.
      */
     public SQLExceptionList(List<? extends Throwable> causeList) {
-        super(String.format("%,d exceptions: %s", causeList.size(), causeList), causeList.get(0));
+        super(String.format("%,d exceptions: %s", causeList == null ? 0 : causeList.size(), causeList),
+                causeList == null ? null : causeList.get(0));
         this.causeList = causeList;
     }
 
     /**
      * Gets the cause list.
-     * 
+     *
      * @return The list of causes.
      */
     public List<? extends Throwable> getCauseList() {
diff --git a/src/test/java/org/apache/commons/dbcp2/TestSQLExceptionList.java b/src/test/java/org/apache/commons/dbcp2/TestSQLExceptionList.java
index ebb0bd8..9a5607b 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestSQLExceptionList.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestSQLExceptionList.java
@@ -35,4 +35,11 @@ public class TestSQLExceptionList {
         Assertions.assertEquals(list, sqlExceptionList.getCauseList());
         sqlExceptionList.printStackTrace();
     }
+
+    @Test
+    public void testNullCause() {
+        final SQLExceptionList sqlExceptionList = new SQLExceptionList(null);
+        Assertions.assertNull(sqlExceptionList.getCause());
+        Assertions.assertNull(sqlExceptionList.getCauseList());
+    }
 }