You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/22 19:36:55 UTC

[logging-log4j2] branch release-2.x updated: Fix NPE in test teardown when something when wrong on set up.

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

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 9f1cfe3  Fix NPE in test teardown when something when wrong on set up.
9f1cfe3 is described below

commit 9f1cfe3389a8bca5bf6dbd86c49c0ba571f45092
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 22 14:36:51 2022 -0500

    Fix NPE in test teardown when something when wrong on set up.
---
 .../log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java      | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java b/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
index 6d90b3c..23c49d2 100644
--- a/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
+++ b/log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
@@ -75,11 +75,12 @@ public abstract class AbstractJpaAppenderTest {
             context.reconfigure();
             StatusLogger.getLogger().reset();
 
-            try (Statement statement = this.connection.createStatement();) {
-                statement.execute("SHUTDOWN");
+            if (this.connection != null) {
+                try (Statement statement = this.connection.createStatement();) {
+                    statement.execute("SHUTDOWN");
+                }
+                this.connection.close();
             }
-
-            this.connection.close();
         }
     }