You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2017/03/13 00:23:22 UTC
logging-log4j2 git commit: [LOG4J2-1850]: Fix Cassandra unit tests on
Windows
Repository: logging-log4j2
Updated Branches:
refs/heads/master 4e1f798cc -> 7091591ae
[LOG4J2-1850]: Fix Cassandra unit tests on Windows
CassandraDaemon attempts to call System.exit() on Windows, so this patch
prevents calls to System.exit() while stopping the daemon.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7091591a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7091591a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7091591a
Branch: refs/heads/master
Commit: 7091591ae33b9feb3b5531b466e7a825d7df99b1
Parents: 4e1f798
Author: Matt Sicker <bo...@gmail.com>
Authored: Sun Mar 12 19:21:57 2017 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Sun Mar 12 19:21:57 2017 -0500
----------------------------------------------------------------------
.../nosql/appender/cassandra/CassandraRule.java | 30 +++++++++++++++++++-
src/changes/changes.xml | 3 ++
2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7091591a/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/cassandra/CassandraRule.java
----------------------------------------------------------------------
diff --git a/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/cassandra/CassandraRule.java b/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/cassandra/CassandraRule.java
index bec97ea..f841727 100644
--- a/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/cassandra/CassandraRule.java
+++ b/log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/cassandra/CassandraRule.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.security.Permission;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadFactory;
@@ -30,6 +31,7 @@ import org.apache.logging.log4j.LoggingException;
import org.apache.logging.log4j.core.util.Cancellable;
import org.apache.logging.log4j.core.util.Closer;
import org.apache.logging.log4j.core.util.Log4jThreadFactory;
+import org.apache.logging.log4j.util.PropertiesUtil;
import org.junit.rules.ExternalResource;
/**
@@ -96,7 +98,33 @@ public class CassandraRule extends ExternalResource {
@Override
public void cancel() {
- daemon.stop();
+ // LOG4J2-1850 Cassandra on Windows calls System.exit in the daemon stop method
+ if (PropertiesUtil.getProperties().isOsWindows()) {
+ cancelOnWindows();
+ } else {
+ daemon.stop();
+ }
+ }
+
+ private void cancelOnWindows() {
+ SecurityManager currentSecurityManager = System.getSecurityManager();
+ try {
+ final SecurityManager securityManager = new SecurityManager() {
+ @Override
+ public void checkPermission(Permission permission) {
+ String permissionName = permission.getName();
+ if (permissionName != null && permissionName.startsWith("exitVM")) {
+ throw new SecurityException("test");
+ }
+ }
+ };
+ System.setSecurityManager(securityManager);
+ daemon.stop();
+ } catch (SecurityException ex) {
+ // ignore
+ } finally {
+ System.setSecurityManager(currentSecurityManager);
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7091591a/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e7f3827..34e1636 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -31,6 +31,9 @@
- "remove" - Removed
-->
<release version="2.8.2" date="2017-MM-DD" description="GA Release 2.8.2">
+ <action issue="LOG4J2-1850" dev="mattsicker" type="fix" due-to="Ludovic Hochet">
+ Fix CassandraRule and unit tests on Windows.
+ </action>
<action issue="LOG4J2-1840" dev="mattsicker" type="fix" due-to="Pradeep Balasundaram">
Fix typo in %replace converter documentation.
</action>