Skip to content

Commit e566e25

Browse files
committed
Clear nonAnnotatedClasses cache in afterSingletonsInstantiated
Issue: SPR-15175
1 parent 5555414 commit e566e25

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,6 +180,9 @@ public void setApplicationContext(ApplicationContext applicationContext) {
180180

181181
@Override
182182
public void afterSingletonsInstantiated() {
183+
// Remove resolved singleton classes from cache
184+
this.nonAnnotatedClasses.clear();
185+
183186
if (this.applicationContext == null) {
184187
// Not running in an ApplicationContext -> register tasks early...
185188
finishRegistration();

spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -96,13 +96,13 @@ public class JmsListenerAnnotationBeanPostProcessor
9696

9797
private String containerFactoryBeanName = DEFAULT_JMS_LISTENER_CONTAINER_FACTORY_BEAN_NAME;
9898

99+
private final MessageHandlerMethodFactoryAdapter messageHandlerMethodFactory =
100+
new MessageHandlerMethodFactoryAdapter();
101+
99102
private BeanFactory beanFactory;
100103

101104
private StringValueResolver embeddedValueResolver;
102105

103-
private final MessageHandlerMethodFactoryAdapter messageHandlerMethodFactory =
104-
new MessageHandlerMethodFactoryAdapter();
105-
106106
private final JmsListenerEndpointRegistrar registrar = new JmsListenerEndpointRegistrar();
107107

108108
private final AtomicInteger counter = new AtomicInteger();
@@ -154,14 +154,17 @@ public void setBeanFactory(BeanFactory beanFactory) {
154154
if (beanFactory instanceof ConfigurableBeanFactory) {
155155
this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
156156
}
157+
this.registrar.setBeanFactory(beanFactory);
157158
}
158159

159160

160161
@Override
161162
public void afterSingletonsInstantiated() {
162-
this.registrar.setBeanFactory(this.beanFactory);
163+
// Remove resolved singleton classes from cache
164+
this.nonAnnotatedClasses.clear();
163165

164166
if (this.beanFactory instanceof ListableBeanFactory) {
167+
// Apply JmsListenerConfigurer beans from the BeanFactory, if any
165168
Map<String, JmsListenerConfigurer> instances =
166169
((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
167170
for (JmsListenerConfigurer configurer : instances.values()) {
@@ -170,6 +173,7 @@ public void afterSingletonsInstantiated() {
170173
}
171174

172175
if (this.registrar.getEndpointRegistry() == null) {
176+
// Determine JmsListenerEndpointRegistry bean from the BeanFactory
173177
if (this.endpointRegistry == null) {
174178
Assert.state(this.beanFactory != null, "BeanFactory must be set to find endpoint registry by bean name");
175179
this.endpointRegistry = this.beanFactory.getBean(

0 commit comments

Comments
 (0)