Skip to content

Commit

Permalink
Merge pull request mvel#48 from tpodom/master
Browse files Browse the repository at this point in the history
MVEL-237 - Clean up ThreadLocals
  • Loading branch information
mikebrock committed Feb 19, 2013
2 parents 6d90ecd + cdd23ba commit e3e7d73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/org/mvel2/MVELRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.mvel2.debug.Debugger;
import org.mvel2.debug.DebuggerContext;
import org.mvel2.integration.VariableResolverFactory;
import org.mvel2.optimizers.OptimizerFactory;
import org.mvel2.util.ErrorUtil;
import org.mvel2.util.ExecutionStack;

Expand Down Expand Up @@ -164,6 +165,9 @@ else if (stk.isEmpty()) {
throw e;
}
}
finally {
OptimizerFactory.clearThreadAccessorOptimizer();
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/mvel2/optimizers/OptimizerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public static void setDefaultOptimizer(String name) {
//noinspection unchecked
AccessorOptimizer ao = accessorCompilers.get(defaultOptimizer = name);
ao.init();
setThreadAccessorOptimizer(ao.getClass());
//clear optimizer so next call to getThreadAccessorOptimizer uses the default again, don't set thread optimizer
//or else static initializers setting the default will unintentionally set up ThreadLocals
threadOptimizer.set(null);
}
catch (Exception e) {
throw new RuntimeException("unable to instantiate accessor compiler", e);
Expand Down

0 comments on commit e3e7d73

Please sign in to comment.