Repository: logging-log4j2 Updated Branches: refs/heads/master e63fd835f -> 5c5431fe3
Use Java 7 try-with-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/5c5431fe Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/5c5431fe Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/5c5431fe Branch: refs/heads/master Commit: 5c5431fe34b5253720f6a8eede219a8626403950 Parents: e63fd83 Author: Gary Gregory <[email protected]> Authored: Sat Jun 13 14:50:33 2015 -0700 Committer: Gary Gregory <[email protected]> Committed: Sat Jun 13 14:50:33 2015 -0700 ---------------------------------------------------------------------- .../logging/log4j/io/LoggerPrintWriterJdbcH2Test.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/5c5431fe/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java index c6e6ea9..2be2569 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java @@ -75,11 +75,8 @@ public class LoggerPrintWriterJdbcH2Test { dataSource.setPassword(PASSWORD); dataSource.setLogWriter(createLoggerPrintWriter()); // dataSource.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); - final Connection conn = dataSource.getConnection(); - try { + try (final Connection conn = dataSource.getConnection()) { conn.prepareCall("select 1"); - } finally { - conn.close(); } Assert.assertTrue(this.getListAppender().getMessages().size() > 0); } @@ -88,13 +85,8 @@ public class LoggerPrintWriterJdbcH2Test { public void testDriverManager_setLogWriter() throws SQLException { DriverManager.setLogWriter(createLoggerPrintWriter()); // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); - try { - final Connection conn = this.newConnection(); - try { - conn.rollback(); - } finally { - conn.close(); - } + try (final Connection conn = this.newConnection()) { + conn.rollback(); } finally { DriverManager.setLogWriter(null); }
