Skip to content

Commit

Permalink
Allow disabling of tccl setting
Browse files Browse the repository at this point in the history
  • Loading branch information
purplefox committed Oct 5, 2015
1 parent 6c1b2f5 commit 37fa8d3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/io/vertx/core/impl/ContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public abstract class ContextImpl implements ContextInternal {

private static final String THREAD_CHECKS_PROP_NAME = "vertx.threadChecks";
private static final String DISABLE_TIMINGS_PROP_NAME = "vertx.disableContextTimings";
private static final String DISABLE_TCCL_PROP_NAME = "vertx.disableTCCL";
private static final boolean THREAD_CHECKS = Boolean.getBoolean(THREAD_CHECKS_PROP_NAME);
private static final boolean DISABLE_TIMINGS = Boolean.getBoolean(DISABLE_TIMINGS_PROP_NAME);
private static final boolean DISABLE_TCCL = Boolean.getBoolean(DISABLE_TCCL_PROP_NAME);

protected final VertxInternal owner;
protected final String deploymentID;
Expand All @@ -61,6 +63,9 @@ public abstract class ContextImpl implements ContextInternal {

protected ContextImpl(VertxInternal vertx, Executor orderedInternalPoolExec, Executor workerExec, String deploymentID, JsonObject config,
ClassLoader tccl) {
if (DISABLE_TCCL && !tccl.getClass().getName().equals("sun.misc.Launcher$AppClassLoader")) {
log.warn("You have disabled TCCL checks but you have a custom TCCL to set.");
}
this.orderedInternalPoolExec = orderedInternalPoolExec;
this.workerExec = workerExec;
this.deploymentID = deploymentID;
Expand All @@ -86,10 +91,12 @@ public static void setContext(ContextImpl context) {

private static void setContext(VertxThread thread, ContextImpl context) {
thread.setContext(context);
if (context != null) {
context.setTCCL();
} else {
Thread.currentThread().setContextClassLoader(null);
if (!DISABLE_TCCL) {
if (context != null) {
context.setTCCL();
} else {
Thread.currentThread().setContextClassLoader(null);
}
}
}

Expand Down

0 comments on commit 37fa8d3

Please sign in to comment.