Commit 30de75c7 authored by Andy Wilkinson's avatar Andy Wilkinson

Ensure that Jetty is completely stopped when it fails to start

Closes gh-12735
parent 399455f6
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -155,9 +155,11 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { ...@@ -155,9 +155,11 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
.info("Jetty started on port(s) " + getActualPortsDescription()); .info("Jetty started on port(s) " + getActualPortsDescription());
} }
catch (EmbeddedServletContainerException ex) { catch (EmbeddedServletContainerException ex) {
stopSilently();
throw ex; throw ex;
} }
catch (Exception ex) { catch (Exception ex) {
stopSilently();
throw new EmbeddedServletContainerException( throw new EmbeddedServletContainerException(
"Unable to start embedded Jetty servlet container", ex); "Unable to start embedded Jetty servlet container", ex);
} }
......
...@@ -357,7 +357,16 @@ public class JettyEmbeddedServletContainerFactoryTests ...@@ -357,7 +357,16 @@ public class JettyEmbeddedServletContainerFactoryTests
}); });
this.thrown.expect(EmbeddedServletContainerException.class); this.thrown.expect(EmbeddedServletContainerException.class);
factory.getEmbeddedServletContainer().start(); JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) factory
.getEmbeddedServletContainer();
try {
jettyContainer.start();
}
finally {
QueuedThreadPool threadPool = (QueuedThreadPool) jettyContainer.getServer()
.getThreadPool();
assertThat(threadPool.isRunning()).isFalse();
}
} }
@Test @Test
......
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