I've a spring boot app version 1.3.3.RELEASE and I've added Spring Cloud Sleuth get those tracing goodies. After adding spring-cloud-sleuth I see some of my async API's are breaking as passed in org.springframework.security.concurrent.DelegatingSecurityContextExecutor.
is null. Short story, I'm using org.springframework.security.concurrent.DelegatingSecurityContextExecutor
from spring security to pass security context around different executors. For that I'm just wrapping those executors into org.springframework.security.concurrent.DelegatingSecurityContextExecutor
instances during application start up. What I'm not sure is why Spring Sleuth is becoming a problem here. The way we're using async processing is, we have created a custom annotation and then created a point cut's around that to inject async behavior.
Example:
public class Async implements AsyncConfigurer {
public Executor getCustomAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//all configuration for thread pool
return new DelegatingSecurityContextAsyncTaskExecutor(executor);
}
public Executor getProcessingExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//all configuration for thread pool
return new DelegatingSecurityContextAsyncTaskExecutor(executor);
}
}
public class MyControllerClass {
@Autowired
private Executor myProcessingExecutor;
@MyCustomAsyncAnnotation
public ResponseObject getResponse() {
//As soon as below code get's executed I get NPE as
//`org.springframework.security.concurrent.DelegatingSecurityContextExecutor.executor` is null. What I'm not sure is why it's null??
// As you see above in my Async class I've registered executor in DelegatingSecurityContextAsyncTaskExecutor, then why it's null here?
//If I remove spring-cloud-sleuth code works fine once again.
CompletableFuture.supplyAsync(() -> ..., myProcessingExecutor);
}
}
class MyCustomAspect {
private Executor myCustomAsyncExecutor;
//create point cut here for those method which have
// @MyCustomAsyncAnnotionation and process it async via above executor.
}
I'm using spring boot 1.3.3.RELEASE, rest easy, spring-security 4.0.3.RELEASE, spring-cloud-sleuth 1.0.12.RELEASE