You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2021/04/07 01:12:03 UTC
[logging-log4j2] branch master updated: Pass system property to
process
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 63b8f29 Pass system property to process
63b8f29 is described below
commit 63b8f294b54622a52981b710f599765cc98a63c0
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Tue Apr 6 12:32:39 2021 -0700
Pass system property to process
---
.../logging/log4j/core/GcFreeLoggingTestUtil.java | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
index d9289b8..94c5fc1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
@@ -29,10 +29,13 @@ import java.io.File;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
+import static java.lang.System.getProperty;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -130,16 +133,24 @@ public enum GcFreeLoggingTestUtil {;
}
public static void runTest(final Class<?> cls) throws Exception {
- final String javaHome = System.getProperty("java.home");
+ final String javaHome = getProperty("java.home");
final String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
- final String classpath = System.getProperty("java.class.path");
+ final String classpath = getProperty("java.class.path");
final String javaagent = "-javaagent:" + agentJar();
+ final String usePreciseClock = System.getProperty("log4j2.usePreciseClock");
final File tempFile = File.createTempFile("allocations", ".txt");
tempFile.deleteOnExit();
-
- final ProcessBuilder builder = new ProcessBuilder( //
- javaBin, javaagent, "-cp", classpath, cls.getName());
+ List<String> command = new ArrayList<>();
+ command.add(javaBin);
+ command.add(javaagent);
+ if (usePreciseClock != null) {
+ command.add("-Dlog4j2.usePreciseClock=" + usePreciseClock);
+ }
+ command.add("-cp");
+ command.add(classpath);
+ command.add(cls.getName());
+ final ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectError(ProcessBuilder.Redirect.to(tempFile));
builder.redirectOutput(ProcessBuilder.Redirect.to(tempFile));
final Process process = builder.start();