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 2015/05/21 06:02:53 UTC

logging-log4j2 git commit: Resourceshould be managed by try-with-resource.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 0419f9cc2 -> 930ac8e40


Resourceshould be managed by try-with-resource.

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

Branch: refs/heads/master
Commit: 930ac8e40a28fb2bb5bcc94a6cb979654937fe74
Parents: 0419f9c
Author: Gary Gregory <ga...@gmail.com>
Authored: Wed May 20 21:02:48 2015 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Wed May 20 21:02:48 2015 -0700

----------------------------------------------------------------------
 .../core/tools/GenerateCustomLoggerTest.java    | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/930ac8e4/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
index 66b4367..5f6bf4d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
@@ -69,20 +69,21 @@ public class GenerateCustomLoggerTest {
         // set up compiler
         final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
         final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
-        final StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
-        final Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(Arrays.asList(f));
-
-        // compile generated source
-        compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
-
-        // check we don't have any compilation errors
         final List<String> errors = new ArrayList<>();
-        for (final Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
-            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
-                errors.add(String.format("Compile error: %s%n", diagnostic.getMessage(Locale.getDefault())));
+        try (final StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null)) {
+            final Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(Arrays
+                    .asList(f));
+
+            // compile generated source
+            compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
+
+            // check we don't have any compilation errors
+            for (final Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
+                if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                    errors.add(String.format("Compile error: %s%n", diagnostic.getMessage(Locale.getDefault())));
+                }
             }
         }
-        fileManager.close();
         assertTrue(errors.toString(), errors.isEmpty());
 
         // load the compiled class