Status: New
Owner: ----
New issue 763 by [email protected]: something is weird, using thread
pool in AOP
http://code.google.com/p/google-guice/issues/detail?id=763
Description of the issue:
using thread pool in AOP: fixedPool.submit
there is weird that fixedPool.submit called a lots times
Steps to reproduce:
let:
final ExecutorService fixedPool = Executors.newFixedThreadPool(10);
@AsyncDBCall
public void ssss(){
System.out.println("ssss");
}
when calling:
@Test
public void aa2222(){
instance.ssss();
}
if I wrote a interceptor (1) or (2), I got:
AsyncDBCall
AsyncDBCall
AsyncDBCall
AsyncDBCall
AsyncDBCall
...
...
...
AsyncDBCall
AsyncDBCall
AsyncDBCall
AsyncDBCall
ssss
(1) bindInterceptor(Matchers.any(),
Matchers.annotatedWith(AsyncDBCall.class), new MethodInterceptor() {
@Override
public Object invoke(final MethodInvocation invocation) throws
Throwable {
fixedPool.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
System.out.println("AsyncDBCall");
return invocation.proceed();
} catch (Throwable throwable) {
throw Throwables.propagate(throwable);
}
}
});
return null;
}
});
(2) bindInterceptor(Matchers.any(),
Matchers.annotatedWith(AsyncDBCall.class), new MethodInterceptor() {
@Override
public Object invoke(final MethodInvocation invocation) throws
Throwable {
fixedPool.submit(new Runnable() {
@Override
public void run() {
try {
System.out.println("AsyncDBCall");
invocation.proceed();
} catch (Throwable throwable) {
throw Throwables.propagate(throwable);
}
}
});
return null;
}
});
using:
/usr/lib/jvm/java-6-openjdk-amd64/bin/java
Attachments:
sql.txt 1.9 KB
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/groups/opt_out.