IDEA-CR-10382 fixes

This commit is contained in:
Alexey Kudravtsev
2016-04-27 13:31:03 +03:00
parent f9130d3606
commit 8c9e4de9df
2 changed files with 18 additions and 10 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.remoteServer.agent.impl;
import com.intellij.util.concurrency.SequentialTaskExecutor;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Proxy;
@@ -38,7 +39,10 @@ public class RemoteAgentThreadProxyCreator {
return agentInterface.cast(Proxy.newProxyInstance(callerClassLoader,
new Class[]{agentInterface},
new ThreadInvocationHandler(callerClassLoader, agentInstance,
myPreWrapperCreator)));
new ThreadInvocationHandler(
SequentialTaskExecutor.createSequentialApplicationPoolExecutor(),
callerClassLoader, agentInstance,
myPreWrapperCreator
)));
}
}
@@ -41,9 +41,9 @@ public class ThreadInvocationHandler implements InvocationHandler {
private final Object myTarget;
private final ChildWrapperCreator myPreWrapperFactory;
public ThreadInvocationHandler(ClassLoader callerClassLoader, Object target,
public ThreadInvocationHandler(ExecutorService taskExecutor, ClassLoader callerClassLoader, Object target,
@Nullable ChildWrapperCreator preWrapperCreator) {
myTaskExecutor = com.intellij.util.concurrency.SequentialTaskExecutor.createSequentialApplicationPoolExecutor();
myTaskExecutor = taskExecutor;
myCallerClassLoader = callerClassLoader;
myTarget = target;
myPreWrapperFactory = preWrapperCreator;
@@ -74,7 +74,7 @@ public class ThreadInvocationHandler implements InvocationHandler {
boolean childCall = method.getAnnotation(ChildCall.class) != null;
if (childCall) {
Object child = immediateCall ? taskCallable.call() : execute(taskCallable);
Object child = immediateCall ? taskCallable.call() : executeAndWait(taskCallable);
if (child == null) {
return null;
}
@@ -118,7 +118,7 @@ public class ThreadInvocationHandler implements InvocationHandler {
return null;
}
else {
return execute(taskCallable);
return executeAndWait(taskCallable);
}
}
finally {
@@ -129,8 +129,9 @@ public class ThreadInvocationHandler implements InvocationHandler {
}
}
private Object execute(Callable<Object> taskCallable) throws Throwable {
Object child;Future<Object> future = myTaskExecutor.submit(taskCallable);
private Object executeAndWait(Callable<Object> taskCallable) throws Throwable {
Object child;
Future<Object> future = myTaskExecutor.submit(taskCallable);
try {
child = future.get();
}
@@ -168,7 +169,10 @@ public class ThreadInvocationHandler implements InvocationHandler {
return Proxy.newProxyInstance(myCallerClassLoader,
new Class[]{callerChildInterface},
new ThreadInvocationHandler(myCallerClassLoader, preWrappedChild,
myPreWrapperFactory));
new ThreadInvocationHandler(
myTaskExecutor,
myCallerClassLoader, preWrappedChild,
myPreWrapperFactory
));
}
}