Added NPE guard for null async executor; fixes gh-2094
This commit is contained in:
@@ -44,10 +44,14 @@ public class LazyTraceAsyncCustomizer extends AsyncConfigurerSupport {
|
||||
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
if (this.delegate.getAsyncExecutor() instanceof LazyTraceExecutor) {
|
||||
return this.delegate.getAsyncExecutor();
|
||||
Executor executor = this.delegate.getAsyncExecutor();
|
||||
if (executor instanceof LazyTraceExecutor) {
|
||||
return executor;
|
||||
}
|
||||
return LazyTraceExecutor.wrap(this.beanFactory, this.delegate.getAsyncExecutor());
|
||||
else if (executor == null) {
|
||||
return null;
|
||||
}
|
||||
return LazyTraceExecutor.wrap(this.beanFactory, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,4 +54,13 @@ public class LazyTraceAsyncCustomizerTest {
|
||||
BDDAssertions.then(executor).isExactlyInstanceOf(LazyTraceExecutor.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_null_when_executor_null() throws Exception {
|
||||
BDDMockito.given(this.asyncConfigurer.getAsyncExecutor()).willReturn(null);
|
||||
|
||||
Executor executor = this.lazyTraceAsyncCustomizer.getAsyncExecutor();
|
||||
|
||||
BDDAssertions.then(executor).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user