From ac7e27b78572ed3e3529d0cf32dc4a89afcf02e5 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 30 Oct 2013 19:30:18 +0100 Subject: [PATCH] Polishing --- .../AbstractApplicationEventMulticaster.java | 15 +++++++-------- .../PostProcessorRegistrationDelegate.java | 6 ++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java index 7ea2b89e5b..92e4fc86c0 100644 --- a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java @@ -136,7 +136,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application protected Collection getApplicationListeners(ApplicationEvent event) { Class eventType = event.getClass(); Object source = event.getSource(); - Class sourceType = (source == null ? null : source.getClass()); + Class sourceType = (source != null ? source.getClass() : null); ListenerCacheKey cacheKey = new ListenerCacheKey(eventType, sourceType); ListenerRetriever retriever = this.retrieverCache.get(cacheKey); if (retriever != null) { @@ -199,11 +199,11 @@ public abstract class AbstractApplicationEventMulticaster implements Application */ private static class ListenerCacheKey { - private final Class eventType; + private final Class eventType; - private final Class sourceType; + private final Class sourceType; - public ListenerCacheKey(Class eventType, Class sourceType) { + public ListenerCacheKey(Class eventType, Class sourceType) { this.eventType = eventType; this.sourceType = sourceType; } @@ -214,14 +214,13 @@ public abstract class AbstractApplicationEventMulticaster implements Application return true; } ListenerCacheKey otherKey = (ListenerCacheKey) other; - return ObjectUtils.nullSafeEquals(this.eventType, otherKey.eventType) - && ObjectUtils.nullSafeEquals(this.sourceType, otherKey.sourceType); + return ObjectUtils.nullSafeEquals(this.eventType, otherKey.eventType) && + ObjectUtils.nullSafeEquals(this.sourceType, otherKey.sourceType); } @Override public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.eventType) * 29 - + ObjectUtils.nullSafeHashCode(this.sourceType); + return ObjectUtils.nullSafeHashCode(this.eventType) * 29 + ObjectUtils.nullSafeHashCode(this.sourceType); } } diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index b2071def0c..7ff0584d9e 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProce import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ApplicationEventMulticaster; import org.springframework.core.OrderComparator; import org.springframework.core.Ordered; import org.springframework.core.PriorityOrdered; @@ -369,8 +370,9 @@ class PostProcessorRegistrationDelegate { @Override public void postProcessBeforeDestruction(Object bean, String beanName) { if (bean instanceof ApplicationListener) { - this.applicationContext.getApplicationEventMulticaster().removeApplicationListener((ApplicationListener) bean); - this.applicationContext.getApplicationEventMulticaster().removeApplicationListenerBean(beanName); + ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster(); + multicaster.removeApplicationListener((ApplicationListener) bean); + multicaster.removeApplicationListenerBean(beanName); } } }