Skip to content

Commit ac7e27b

Browse files
committed
Polishing
1 parent 9cbac98 commit ac7e27b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected Collection<ApplicationListener> getApplicationListeners() {
136136
protected Collection<ApplicationListener> getApplicationListeners(ApplicationEvent event) {
137137
Class<? extends ApplicationEvent> eventType = event.getClass();
138138
Object source = event.getSource();
139-
Class sourceType = (source == null ? null : source.getClass());
139+
Class<?> sourceType = (source != null ? source.getClass() : null);
140140
ListenerCacheKey cacheKey = new ListenerCacheKey(eventType, sourceType);
141141
ListenerRetriever retriever = this.retrieverCache.get(cacheKey);
142142
if (retriever != null) {
@@ -199,11 +199,11 @@ protected boolean supportsEvent(
199199
*/
200200
private static class ListenerCacheKey {
201201

202-
private final Class eventType;
202+
private final Class<?> eventType;
203203

204-
private final Class sourceType;
204+
private final Class<?> sourceType;
205205

206-
public ListenerCacheKey(Class eventType, Class sourceType) {
206+
public ListenerCacheKey(Class<?> eventType, Class<?> sourceType) {
207207
this.eventType = eventType;
208208
this.sourceType = sourceType;
209209
}
@@ -214,14 +214,13 @@ public boolean equals(Object other) {
214214
return true;
215215
}
216216
ListenerCacheKey otherKey = (ListenerCacheKey) other;
217-
return ObjectUtils.nullSafeEquals(this.eventType, otherKey.eventType)
218-
&& ObjectUtils.nullSafeEquals(this.sourceType, otherKey.sourceType);
217+
return ObjectUtils.nullSafeEquals(this.eventType, otherKey.eventType) &&
218+
ObjectUtils.nullSafeEquals(this.sourceType, otherKey.sourceType);
219219
}
220220

221221
@Override
222222
public int hashCode() {
223-
return ObjectUtils.nullSafeHashCode(this.eventType) * 29
224-
+ ObjectUtils.nullSafeHashCode(this.sourceType);
223+
return ObjectUtils.nullSafeHashCode(this.eventType) * 29 + ObjectUtils.nullSafeHashCode(this.sourceType);
225224
}
226225
}
227226

spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
3838
import org.springframework.beans.factory.support.RootBeanDefinition;
3939
import org.springframework.context.ApplicationListener;
40+
import org.springframework.context.event.ApplicationEventMulticaster;
4041
import org.springframework.core.OrderComparator;
4142
import org.springframework.core.Ordered;
4243
import org.springframework.core.PriorityOrdered;
@@ -369,8 +370,9 @@ else if (flag == null) {
369370
@Override
370371
public void postProcessBeforeDestruction(Object bean, String beanName) {
371372
if (bean instanceof ApplicationListener) {
372-
this.applicationContext.getApplicationEventMulticaster().removeApplicationListener((ApplicationListener) bean);
373-
this.applicationContext.getApplicationEventMulticaster().removeApplicationListenerBean(beanName);
373+
ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
374+
multicaster.removeApplicationListener((ApplicationListener) bean);
375+
multicaster.removeApplicationListenerBean(beanName);
374376
}
375377
}
376378
}

0 commit comments

Comments
 (0)