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 2015/09/29 13:39:37 UTC
[07/21] logging-log4j2 git commit: Use try-with-resources.
Use 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/20520762
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/20520762
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/20520762
Branch: refs/heads/LOG4J-1012
Commit: 20520762ab793d95ff407bcab319837b985a5bed
Parents: 30806ad
Author: ggregory <gg...@apache.org>
Authored: Mon Sep 28 23:53:07 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Mon Sep 28 23:53:07 2015 -0700
----------------------------------------------------------------------
.../core/tools/GenerateExtendedLoggerTest.java | 23 ++++++++++----------
1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20520762/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
index ccf12d0..7f27c9d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
@@ -72,20 +72,21 @@ public class GenerateExtendedLoggerTest {
// 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