Source:
<code>private Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable { boolean suppressExceptions = false; ComponentStatus status = componentRegistry.getStatus(); if (status.isTerminated()) { throw new IllegalStateException(String.format( "%s is in 'TERMINATED' state and so it does not accept new invocations. " + "Either restart it or recreate the cache container.", getCacheNamePrefix())); } else if (stoppingAndNotAllowed(status, ctx)) { throw new IllegalStateException(String.format( "%s is in 'STOPPING' state and this is an invocation not belonging to an on-going transaction, so it does not accept new invocations. " + "Either restart it or recreate the cache container.", getCacheNamePrefix())); } <START> NDC.push(componentRegistry.getCacheName()); <END> try { if (trace) log.tracef("Invoked with command %s and InvocationContext [%s]", command, ctx); if (ctx == null) throw new IllegalStateException("Null context not allowed!!"); if (ctx.hasFlag(Flag.FAIL_SILENTLY)) { suppressExceptions = true; } try { return invokeNextInterceptor(ctx, command); } catch (Throwable th) { if (suppressExceptions) { log.trace("Exception while executing code, failing silently...", th); return null; } else { log.executionError(th); if (ctx.isInTxScope() && ctx.isOriginLocal()) { if (trace) log.trace("Transaction marked for rollback as exception was received."); markTxForRollbackAndRethrow(ctx, th); throw new IllegalStateException("This should not be reached"); } throw th; } } finally { ctx.reset(); } } finally { NDC.pop(); } }</code><technical_language>Is NDC.push() expensive? If so, this in if (trace) { ... } block</technical_language>

Target:
private Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable { boolean suppressExceptions = false; ComponentStatus status = componentRegistry.getStatus(); if (status.isTerminated()) { throw new IllegalStateException(String.format( "%s is in 'TERMINATED' state and so it does not accept new invocations. " + "Either restart it or recreate the cache container.", getCacheNamePrefix())); } else if (stoppingAndNotAllowed(status, ctx)) { throw new IllegalStateException(String.format( "%s is in 'STOPPING' state and this is an invocation not belonging to an on-going transaction, so it does not accept new invocations. " + "Either restart it or recreate the cache container.", getCacheNamePrefix())); } LogFactory.pushNDC(componentRegistry.getCacheName(), trace); try { if (trace) log.tracef("Invoked with command %s and InvocationContext [%s]", command, ctx); if (ctx == null) throw new IllegalStateException("Null context not allowed!!"); if (ctx.hasFlag(Flag.FAIL_SILENTLY)) { suppressExceptions = true; } try { return invokeNextInterceptor(ctx, command); } catch (Throwable th) { if (suppressExceptions) { log.trace("Exception while executing code, failing silently...", th); return null; } else { log.executionError(th); if (ctx.isInTxScope() && ctx.isOriginLocal()) { if (trace) log.trace("Transaction marked for rollback as exception was received."); markTxForRollbackAndRethrow(ctx, th); throw new IllegalStateException("This should not be reached"); } throw th; } } finally { ctx.reset(); } } finally { LogFactory.popNDC(trace); } }