Copy Context before start in Trampoline
The CommandFactoryProvider uses a Trampoline class to put each command into the Executor. In doing so it keeps a Context which the Runnable it creates has access to in its catch block and its toString() method. Since the ctx variable which stores this in the Trampoline class is nulled out in the public destroy() method, an NPE can occur when the Runnable is used. I have seen an NPE on our server on the toString() line when I repeatedly query the queue. To avoid the ctx var from being nulled out by the destroy method, copy it first into the Runnables scope. Change-Id: Ia7e6cc46c0b96dc9a3a7b4c8e606235918d3e7c1
This commit is contained in:
@@ -109,6 +109,7 @@ class CommandFactoryProvider implements Provider<CommandFactory> {
|
||||
|
||||
public void start(final Environment env) throws IOException {
|
||||
this.env = env;
|
||||
final Context ctx = this.ctx;
|
||||
startExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user