Merge branch '3.3.x'
This commit is contained in:
commit
724dea634d
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.boot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -103,12 +105,13 @@ class SpringApplicationShutdownHook implements Runnable {
|
|||
public void run() {
|
||||
Set<ConfigurableApplicationContext> contexts;
|
||||
Set<ConfigurableApplicationContext> closedContexts;
|
||||
Set<Handler> handlers;
|
||||
List<Handler> handlers;
|
||||
synchronized (SpringApplicationShutdownHook.class) {
|
||||
this.inProgress = true;
|
||||
contexts = new LinkedHashSet<>(this.contexts);
|
||||
closedContexts = new LinkedHashSet<>(this.closedContexts);
|
||||
handlers = new LinkedHashSet<>(this.handlers.getActions());
|
||||
handlers = new ArrayList<>(this.handlers.getActions());
|
||||
Collections.reverse(handlers);
|
||||
}
|
||||
contexts.forEach(this::closeAndWait);
|
||||
closedContexts.forEach(this::closeAndWait);
|
||||
|
|
|
@ -207,7 +207,7 @@ class SpringApplicationShutdownHookTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void handlersRunInDeterministicOrder() {
|
||||
void handlersRunInDeterministicOrderFromLastRegisteredToFirst() {
|
||||
TestSpringApplicationShutdownHook shutdownHook = new TestSpringApplicationShutdownHook();
|
||||
Runnable r1 = mock(Runnable.class);
|
||||
Runnable r2 = mock(Runnable.class);
|
||||
|
@ -217,9 +217,9 @@ class SpringApplicationShutdownHookTests {
|
|||
shutdownHook.getHandlers().add(r3);
|
||||
shutdownHook.run();
|
||||
InOrder ordered = inOrder(r1, r2, r3);
|
||||
ordered.verify(r2).run();
|
||||
ordered.verify(r1).run();
|
||||
ordered.verify(r3).run();
|
||||
ordered.verify(r1).run();
|
||||
ordered.verify(r2).run();
|
||||
ordered.verifyNoMoreInteractions();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue