Polish
This commit is contained in:
parent
0d5c30fdcc
commit
1f1a7e0ed3
|
@ -26,6 +26,7 @@ import org.springframework.context.ApplicationListener;
|
|||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Listener that closes the application context if its parent is closed. It listens for
|
||||
|
@ -77,6 +78,9 @@ public class ParentContextCloserApplicationListener implements
|
|||
return new ContextCloserListener(child);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ApplicationListener} to close the context.
|
||||
*/
|
||||
protected static class ContextCloserListener implements
|
||||
ApplicationListener<ContextClosedEvent> {
|
||||
|
||||
|
@ -99,31 +103,23 @@ public class ParentContextCloserApplicationListener implements
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime
|
||||
* result
|
||||
+ ((this.childContext.get() == null) ? 0 : this.childContext.get()
|
||||
.hashCode());
|
||||
return result;
|
||||
return ObjectUtils.nullSafeHashCode(this.childContext.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof ContextCloserListener) {
|
||||
ContextCloserListener other = (ContextCloserListener) obj;
|
||||
if (this.childContext.get() == null) {
|
||||
if (other.childContext.get() != null)
|
||||
return false;
|
||||
return ObjectUtils.nullSafeEquals(this.childContext.get(),
|
||||
other.childContext.get());
|
||||
}
|
||||
else if (!this.childContext.get().equals(other.childContext.get()))
|
||||
return false;
|
||||
return true;
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,10 +90,9 @@ public class EventPublishingRunListener implements SpringApplicationRunListener
|
|||
@Override
|
||||
public void finished(ConfigurableApplicationContext context, Throwable exception) {
|
||||
if (exception != null) {
|
||||
publishEvent(new ApplicationFailedEvent(this.application, this.args, context,
|
||||
exception));
|
||||
}
|
||||
else {
|
||||
ApplicationFailedEvent event = new ApplicationFailedEvent(this.application,
|
||||
this.args, context, exception);
|
||||
publishEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ import static org.mockito.Mockito.verify;
|
|||
* Tests for {@link SpringApplication}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SpringApplicationTests {
|
||||
|
||||
|
|
Loading…
Reference in New Issue