|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
62 | 62 | import org.springframework.core.env.ConfigurableEnvironment;
|
63 | 63 | import org.springframework.core.env.StandardEnvironment;
|
64 | 64 | import org.springframework.core.io.DescriptiveResource;
|
| 65 | +import org.springframework.core.task.SimpleAsyncTaskExecutor; |
| 66 | +import org.springframework.core.task.SyncTaskExecutor; |
65 | 67 | import org.springframework.stereotype.Component;
|
66 | 68 | import org.springframework.util.Assert;
|
67 | 69 | import org.springframework.util.ObjectUtils;
|
@@ -375,6 +377,18 @@ public void postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed() {
|
375 | 377 | .withMessageContaining(TestBean.class.getName());
|
376 | 378 | }
|
377 | 379 |
|
| 380 | + @Test // gh-25430 |
| 381 | + public void detectAliasOverride() { |
| 382 | + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); |
| 383 | + DefaultListableBeanFactory beanFactory = context.getDefaultListableBeanFactory(); |
| 384 | + beanFactory.setAllowBeanDefinitionOverriding(false); |
| 385 | + context.register(FirstConfiguration.class, SecondConfiguration.class); |
| 386 | + assertThatIllegalStateException().isThrownBy(context::refresh) |
| 387 | + .withMessageContaining("alias 'taskExecutor'") |
| 388 | + .withMessageContaining("name 'applicationTaskExecutor'") |
| 389 | + .withMessageContaining("bean definition 'taskExecutor'"); |
| 390 | + } |
| 391 | + |
378 | 392 | @Test
|
379 | 393 | public void configurationClassesProcessedInCorrectOrder() {
|
380 | 394 | beanFactory.registerBeanDefinition("config1", new RootBeanDefinition(OverridingSingletonBeanConfig.class));
|
@@ -1266,6 +1280,24 @@ static class LoadedConfig {
|
1266 | 1280 | }
|
1267 | 1281 | }
|
1268 | 1282 |
|
| 1283 | + @Configuration |
| 1284 | + static class FirstConfiguration { |
| 1285 | + |
| 1286 | + @Bean |
| 1287 | + SyncTaskExecutor taskExecutor() { |
| 1288 | + return new SyncTaskExecutor(); |
| 1289 | + } |
| 1290 | + } |
| 1291 | + |
| 1292 | + @Configuration |
| 1293 | + static class SecondConfiguration { |
| 1294 | + |
| 1295 | + @Bean(name = {"applicationTaskExecutor", "taskExecutor"}) |
| 1296 | + SimpleAsyncTaskExecutor simpleAsyncTaskExecutor() { |
| 1297 | + return new SimpleAsyncTaskExecutor(); |
| 1298 | + } |
| 1299 | + } |
| 1300 | + |
1269 | 1301 | public static class ScopedProxyConsumer {
|
1270 | 1302 |
|
1271 | 1303 | @Autowired
|
|
0 commit comments