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/06/19 20:01:19 UTC
[26/40] 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/c80735fa
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c80735fa
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c80735fa
Branch: refs/heads/LOG4J-1181
Commit: c80735fadd6c6442fa76d938da4263104de8a98b
Parents: abd1010
Author: ggregory <gg...@apache.org>
Authored: Fri Jun 17 17:44:30 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Jun 17 17:44:30 2016 -0700
----------------------------------------------------------------------
.../log4j/core/appender/FileAppenderTest.java | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c80735fa/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
index edfcd46..8cf5f10 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
@@ -139,15 +139,14 @@ public class FileAppenderTest {
@Test
@Ignore
public void testMultipleVMs() throws Exception {
-
final String classPath = System.getProperty("java.class.path");
final Integer count = 10;
final int processeCount = 3;
final Process[] processes = new Process[processeCount];
final ProcessBuilder[] builders = new ProcessBuilder[processeCount];
for (int index = 0; index < processeCount; ++index) {
- builders[index] = new ProcessBuilder("java", "-cp", classPath, ProcessTest.class.getName(), "Process "
- + index, count.toString(), "true");
+ builders[index] = new ProcessBuilder("java", "-cp", classPath, ProcessTest.class.getName(),
+ "Process " + index, count.toString(), "true");
}
for (int index = 0; index < processeCount; ++index) {
processes[index] = builders[index].start();
@@ -155,14 +154,12 @@ public class FileAppenderTest {
for (int index = 0; index < processeCount; ++index) {
final Process process = processes[index];
// System.out.println("Process " + index + " exited with " + p.waitFor());
- final InputStream is = process.getInputStream();
- final InputStreamReader isr = new InputStreamReader(is);
- final BufferedReader br = new BufferedReader(isr);
- String line;
- while ((line = br.readLine()) != null) {
- System.out.println(line);
+ try (final BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
}
- is.close();
process.destroy();
}
verifyFile(count * processeCount);