Polish multiple root contexts in Restarter
See gh-7335 See gh-7336
This commit is contained in:
@@ -45,15 +45,14 @@ public class RestartApplicationListener
|
|||||||
onApplicationStartingEvent((ApplicationStartingEvent) event);
|
onApplicationStartingEvent((ApplicationStartingEvent) event);
|
||||||
}
|
}
|
||||||
if (event instanceof ApplicationPreparedEvent) {
|
if (event instanceof ApplicationPreparedEvent) {
|
||||||
Restarter.getInstance()
|
onApplicationPreparedEvent((ApplicationPreparedEvent) event);
|
||||||
.prepare(((ApplicationPreparedEvent) event).getApplicationContext());
|
|
||||||
}
|
}
|
||||||
if (event instanceof ApplicationReadyEvent
|
if (event instanceof ApplicationReadyEvent
|
||||||
|| event instanceof ApplicationFailedEvent) {
|
|| event instanceof ApplicationFailedEvent) {
|
||||||
Restarter.getInstance().finish();
|
Restarter.getInstance().finish();
|
||||||
if (event instanceof ApplicationFailedEvent) {
|
}
|
||||||
Restarter.getInstance().remove(((ApplicationFailedEvent) event).getApplicationContext());
|
if (event instanceof ApplicationFailedEvent) {
|
||||||
}
|
onApplicationFailedEvent((ApplicationFailedEvent) event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +71,14 @@ public class RestartApplicationListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onApplicationPreparedEvent(ApplicationPreparedEvent event) {
|
||||||
|
Restarter.getInstance().prepare(event.getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onApplicationFailedEvent(ApplicationFailedEvent event) {
|
||||||
|
Restarter.getInstance().remove(event.getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,11 +315,9 @@ public class Restarter {
|
|||||||
this.logger.debug("Stopping application");
|
this.logger.debug("Stopping application");
|
||||||
this.stopLock.lock();
|
this.stopLock.lock();
|
||||||
try {
|
try {
|
||||||
if (!CollectionUtils.isEmpty(this.rootContexts)) {
|
for (ConfigurableApplicationContext context : this.rootContexts) {
|
||||||
for (ConfigurableApplicationContext rootContext : this.rootContexts) {
|
context.close();
|
||||||
rootContext.close();
|
this.rootContexts.remove(context);
|
||||||
}
|
|
||||||
this.rootContexts.clear();
|
|
||||||
}
|
}
|
||||||
cleanupCaches();
|
cleanupCaches();
|
||||||
if (this.forceReferenceCleanup) {
|
if (this.forceReferenceCleanup) {
|
||||||
|
|||||||
Reference in New Issue
Block a user