Commit 4451df21 authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.2.x'

parents e06198e9 f08f8727
...@@ -146,9 +146,9 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext ...@@ -146,9 +146,9 @@ public class EmbeddedWebApplicationContext extends GenericWebApplicationContext
} }
@Override @Override
protected void doClose() { protected void onClose() {
super.onClose();
stopAndReleaseEmbeddedServletContainer(); stopAndReleaseEmbeddedServletContainer();
super.doClose();
} }
private synchronized void createEmbeddedServletContainer() { private synchronized void createEmbeddedServletContainer() {
......
...@@ -43,14 +43,11 @@ import org.mockito.MockitoAnnotations; ...@@ -43,14 +43,11 @@ import org.mockito.MockitoAnnotations;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.Scope; import org.springframework.beans.factory.config.Scope;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory.MockEmbeddedServletContainer;
import org.springframework.boot.context.web.ServerPortInfoApplicationContextInitializer; import org.springframework.boot.context.web.ServerPortInfoApplicationContextInitializer;
import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
...@@ -68,7 +65,6 @@ import org.springframework.web.filter.GenericFilterBean; ...@@ -68,7 +65,6 @@ import org.springframework.web.filter.GenericFilterBean;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.sameInstance; import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -485,21 +481,6 @@ public class EmbeddedWebApplicationContextTests { ...@@ -485,21 +481,6 @@ public class EmbeddedWebApplicationContextTests {
sameInstance(scope)); sameInstance(scope));
} }
@Test
public void containerIsStoppedBeforeContextIsClosed() {
addEmbeddedServletContainerFactoryBean();
this.context.registerBeanDefinition("shutdownOrderingValidator",
BeanDefinitionBuilder.rootBeanDefinition(ShutdownOrderingValidator.class)
.addConstructorArgReference("embeddedServletContainerFactory")
.getBeanDefinition());
this.context.refresh();
ShutdownOrderingValidator validator = this.context
.getBean(ShutdownOrderingValidator.class);
this.context.close();
assertThat(validator.destroyed, is(true));
assertThat(validator.containerStoppedFirst, is(true));
}
private void addEmbeddedServletContainerFactoryBean() { private void addEmbeddedServletContainerFactoryBean() {
this.context.registerBeanDefinition("embeddedServletContainerFactory", this.context.registerBeanDefinition("embeddedServletContainerFactory",
new RootBeanDefinition(MockEmbeddedServletContainerFactory.class)); new RootBeanDefinition(MockEmbeddedServletContainerFactory.class));
...@@ -552,25 +533,4 @@ public class EmbeddedWebApplicationContextTests { ...@@ -552,25 +533,4 @@ public class EmbeddedWebApplicationContextTests {
} }
protected static class ShutdownOrderingValidator implements DisposableBean {
private final MockEmbeddedServletContainer servletContainer;
private boolean destroyed = false;
private boolean containerStoppedFirst = false;
ShutdownOrderingValidator(
MockEmbeddedServletContainerFactory servletContainerFactory) {
this.servletContainer = servletContainerFactory.getContainer();
}
@Override
public void destroy() {
this.destroyed = true;
this.containerStoppedFirst = this.servletContainer.isStopped();
}
}
} }
...@@ -90,8 +90,6 @@ public class MockEmbeddedServletContainerFactory ...@@ -90,8 +90,6 @@ public class MockEmbeddedServletContainerFactory
private final int port; private final int port;
private boolean stopped = false;
public MockEmbeddedServletContainer(ServletContextInitializer[] initializers, public MockEmbeddedServletContainer(ServletContextInitializer[] initializers,
int port) { int port) {
this.initializers = initializers; this.initializers = initializers;
...@@ -176,11 +174,6 @@ public class MockEmbeddedServletContainerFactory ...@@ -176,11 +174,6 @@ public class MockEmbeddedServletContainerFactory
public void stop() { public void stop() {
this.servletContext = null; this.servletContext = null;
this.registeredServlets.clear(); this.registeredServlets.clear();
this.stopped = true;
}
public boolean isStopped() {
return this.stopped;
} }
public Servlet[] getServlets() { public Servlet[] getServlets() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment