Skip to content

Commit 155bbb8

Browse files
committed
Clear nonAnnotatedClasses cache in afterSingletonsInstantiated
Issue: SPR-15175 (cherry picked from commit e566e25)
1 parent 4f690ee commit 155bbb8

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.
@@ -182,6 +182,9 @@ public void setApplicationContext(ApplicationContext applicationContext) {
182182

183183
@Override
184184
public void afterSingletonsInstantiated() {
185+
// Remove resolved singleton classes from cache
186+
this.nonAnnotatedClasses.clear();
187+
185188
if (this.applicationContext == null) {
186189
// Not running in an ApplicationContext -> register tasks early...
187190
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();
@@ -155,14 +155,17 @@ public void setBeanFactory(BeanFactory beanFactory) {
155155
if (beanFactory instanceof ConfigurableBeanFactory) {
156156
this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
157157
}
158+
this.registrar.setBeanFactory(beanFactory);
158159
}
159160

160161

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

165167
if (this.beanFactory instanceof ListableBeanFactory) {
168+
// Apply JmsListenerConfigurer beans from the BeanFactory, if any
166169
Map<String, JmsListenerConfigurer> instances =
167170
((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
168171
for (JmsListenerConfigurer configurer : instances.values()) {
@@ -171,6 +174,7 @@ public void afterSingletonsInstantiated() {
171174
}
172175

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

0 commit comments

Comments
 (0)