Skip to content

Commit

Permalink
[LOGMGR-172] Ensure initializing the StandardOutputStreams are initia…
Browse files Browse the repository at this point in the history
…lized in a privileged block if required.
  • Loading branch information
jamezp committed Aug 31, 2017
1 parent 036830e commit 50cfd0c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/main/java/org/jboss/logmanager/LogManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public final class LogManager extends java.util.logging.LogManager {
static final boolean PER_THREAD_LOG_FILTER;

static {
try {
// Ensure the StandardOutputStreams are initialized early to capture the current System.out and System.err.
Class.forName(StandardOutputStreams.class.getName());
} catch (ClassNotFoundException ignore) {
}
if (System.getSecurityManager() == null) {
try {
// Ensure the StandardOutputStreams are initialized early to capture the current System.out and System.err.
Class.forName(StandardOutputStreams.class.getName(), true, LogManager.class.getClassLoader());
} catch (ClassNotFoundException ignore) {
}
PER_THREAD_LOG_FILTER = Boolean.getBoolean(PER_THREAD_LOG_FILTER_KEY);
} else {
PER_THREAD_LOG_FILTER = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
Expand All @@ -64,6 +64,18 @@ public Boolean run() {
return Boolean.getBoolean(PER_THREAD_LOG_FILTER_KEY);
}
});

AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
try {
// Ensure the StandardOutputStreams are initialized early to capture the current System.out and System.err.
Class.forName(StandardOutputStreams.class.getName(), true, LogManager.class.getClassLoader());
} catch (ClassNotFoundException ignore) {
}
return null;
}
});
}
}

Expand Down

0 comments on commit 50cfd0c

Please sign in to comment.