You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/08/30 09:27:22 UTC

[05/24] logging-log4j2 git commit: Use try-with-resources for JDBC resources.

Use try-with-resources for JDBC resources.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/94072a1e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/94072a1e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/94072a1e

Branch: refs/heads/LOG4J2-1528
Commit: 94072a1ec7802b493e1caeb57fd05b29df288afc
Parents: b6ecddc
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 28 13:34:26 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 28 13:34:26 2016 -0700

----------------------------------------------------------------------
 .../core/appender/db/jpa/JpaH2AppenderTest.java | 28 +++++++++-----------
 1 file changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/94072a1e/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JpaH2AppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JpaH2AppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JpaH2AppenderTest.java
index 638fbe4..6e80d9e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JpaH2AppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JpaH2AppenderTest.java
@@ -35,21 +35,19 @@ public class JpaH2AppenderTest extends AbstractJpaAppenderTest {
     protected Connection setUpConnection() throws SQLException {
         final Connection connection = DriverManager.getConnection("jdbc:h2:mem:Log4j", USER_ID, PASSWORD);
 
-        Statement statement = connection.createStatement();
-        statement.executeUpdate("CREATE TABLE jpaBaseLogEntry ( " +
-                "id INTEGER IDENTITY, eventDate DATETIME, level NVARCHAR(10), logger NVARCHAR(255), " +
-                "message NVARCHAR(1024), exception NVARCHAR(1048576)" +
-                " )");
-        statement.close();
-
-        statement = connection.createStatement();
-        statement.executeUpdate("CREATE TABLE jpaBasicLogEntry ( " +
-                "id INTEGER IDENTITY, timemillis BIGINT, nanoTime BIGINT, level NVARCHAR(10), loggerName NVARCHAR(255), " +
-                "message NVARCHAR(1024), thrown NVARCHAR(1048576), contextMapJson NVARCHAR(1048576)," +
-                "loggerFQCN NVARCHAR(1024), contextStack NVARCHAR(1048576), marker NVARCHAR(255), source NVARCHAR(2048)," +
-                "threadId BIGINT, threadName NVARCHAR(255), threadPriority INTEGER" +
-                " )");
-        statement.close();
+        try (Statement statement = connection.createStatement()) {
+            statement.executeUpdate("CREATE TABLE jpaBaseLogEntry ( "
+                    + "id INTEGER IDENTITY, eventDate DATETIME, level NVARCHAR(10), logger NVARCHAR(255), "
+                    + "message NVARCHAR(1024), exception NVARCHAR(1048576)" + " )");
+        }
+
+        try (Statement statement = connection.createStatement()) {
+            statement.executeUpdate("CREATE TABLE jpaBasicLogEntry ( "
+                    + "id INTEGER IDENTITY, timemillis BIGINT, nanoTime BIGINT, level NVARCHAR(10), loggerName NVARCHAR(255), "
+                    + "message NVARCHAR(1024), thrown NVARCHAR(1048576), contextMapJson NVARCHAR(1048576),"
+                    + "loggerFQCN NVARCHAR(1024), contextStack NVARCHAR(1048576), marker NVARCHAR(255), source NVARCHAR(2048),"
+                    + "threadId BIGINT, threadName NVARCHAR(255), threadPriority INTEGER" + " )");
+        }
 
         return connection;
     }