Skip to content

Commit

Permalink
Ensure log.isTraceEnabled() is invoked consistently for the LogFactor…
Browse files Browse the repository at this point in the history
…y.pushNDC
  • Loading branch information
Sanne committed Nov 7, 2011
1 parent 5ef8fcc commit ad802a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Expand Up @@ -113,7 +113,8 @@ public void init(CacheViewsManager cacheViewsManager) {
}

public Object perform(InvocationContext ctx) throws Throwable {
LogFactory.pushNDC(cacheName, log.isTraceEnabled());
final boolean trace = log.isTraceEnabled();
LogFactory.pushNDC(cacheName, trace);
try {
switch (type) {
case REQUEST_JOIN:
Expand Down Expand Up @@ -141,7 +142,7 @@ public Object perform(InvocationContext ctx) throws Throwable {
log.exceptionHandlingCommand(this, t);
throw t;
} finally {
LogFactory.popNDC(log.isTraceEnabled());
LogFactory.popNDC(trace);
}
}

Expand Down
Expand Up @@ -99,7 +99,8 @@ public void init(StateTransferManager stateTransferManager, Configuration config
}

public Object perform(InvocationContext ctx) throws Throwable {
LogFactory.pushNDC(configuration.getName(), log.isTraceEnabled());
final boolean trace = log.isTraceEnabled();
LogFactory.pushNDC(configuration.getName(), trace);
stateTransferManager.waitForJoinToStart();
try {
switch (type) {
Expand All @@ -113,7 +114,7 @@ public Object perform(InvocationContext ctx) throws Throwable {
log.exceptionHandlingCommand(this, t);
return null;
} finally {
LogFactory.popNDC(log.isTraceEnabled());
LogFactory.popNDC(trace);
}
}

Expand Down
Expand Up @@ -101,7 +101,7 @@ public void init(Configuration configuration, RpcManager rpcManager, CommandsFac
// The DMI is cache-scoped, so it will always start after the RMI, which is global-scoped
@Start(priority = 20)
private void start() throws Exception {
log.tracef("starting distribution manager on %s", getAddress());
if (trace) log.tracef("starting distribution manager on %s", getAddress());
consistentHash = ConsistentHashHelper.createConsistentHash(configuration, Collections.singleton(rpcManager.getAddress()));
}

Expand Down
Expand Up @@ -549,7 +549,7 @@ public boolean isCoordinator() {
}

private Cache createCache(String cacheName) {
boolean trace = log.isTraceEnabled();
final boolean trace = log.isTraceEnabled();
LogFactory.pushNDC(cacheName, trace);
try {
Cache cache = wireCache(cacheName);
Expand Down

0 comments on commit ad802a5

Please sign in to comment.