Merge pull request #44447 from izeye

* pr/44447:
  Polish

Closes gh-44447
This commit is contained in:
Stéphane Nicoll 2025-03-12 08:55:10 +01:00
commit 090024512c
5 changed files with 13 additions and 11 deletions

View File

@ -44,7 +44,7 @@ import org.springframework.context.annotation.DependsOn;
public @interface AutoConfigureBefore { public @interface AutoConfigureBefore {
/** /**
* The auto-configure classes that should have not yet been applied. * The auto-configuration classes that should have not yet been applied.
* @return the classes * @return the classes
*/ */
Class<?>[] value() default {}; Class<?>[] value() default {};

View File

@ -146,15 +146,15 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon
super.refresh(); super.refresh();
} }
catch (RuntimeException ex) { catch (RuntimeException ex) {
try { WebServer webServer = this.webServer;
WebServer webServer = this.webServer; if (webServer != null) {
if (webServer != null) { try {
webServer.stop(); webServer.stop();
webServer.destroy(); webServer.destroy();
} }
} catch (RuntimeException stopOrDestroyEx) {
catch (RuntimeException stopOrDestroyEx) { ex.addSuppressed(stopOrDestroyEx);
ex.addSuppressed(stopOrDestroyEx); }
} }
throw ex; throw ex;
} }

View File

@ -44,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
/** /**
@ -148,7 +149,7 @@ class ReactiveWebServerApplicationContextTests {
.withStackTraceContaining("WebServer has failed to stop"); .withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer(); WebServer webServer = this.context.getWebServer();
then(webServer).should().stop(); then(webServer).should().stop();
then(webServer).should(times(0)).destroy(); then(webServer).should(never()).destroy();
} }
@Test @Test

View File

@ -86,6 +86,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.withSettings; import static org.mockito.Mockito.withSettings;
@ -236,7 +237,7 @@ class ServletWebServerApplicationContextTests {
.withStackTraceContaining("WebServer has failed to stop"); .withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer(); WebServer webServer = this.context.getWebServer();
then(webServer).should().stop(); then(webServer).should().stop();
then(webServer).should(times(0)).destroy(); then(webServer).should(never()).destroy();
} }
@Test @Test

View File

@ -166,7 +166,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.never;
/** /**
* Base for testing classes that extends {@link AbstractServletWebServerFactory}. * Base for testing classes that extends {@link AbstractServletWebServerFactory}.
@ -1195,7 +1195,7 @@ public abstract class AbstractServletWebServerFactoryTests {
this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener)); this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener));
this.webServer.start(); this.webServer.start();
this.webServer.stop(); this.webServer.stop();
then(listener).should(times(0)).contextDestroyed(any(ServletContextEvent.class)); then(listener).should(never()).contextDestroyed(any(ServletContextEvent.class));
} }
@Test @Test