Ensure that Jetty is completely stopped when it fails to start
Closes gh-12735
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -155,9 +155,11 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
|
||||
.info("Jetty started on port(s) " + getActualPortsDescription());
|
||||
}
|
||||
catch (EmbeddedServletContainerException ex) {
|
||||
stopSilently();
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
stopSilently();
|
||||
throw new EmbeddedServletContainerException(
|
||||
"Unable to start embedded Jetty servlet container", ex);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,16 @@ public class JettyEmbeddedServletContainerFactoryTests
|
||||
|
||||
});
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user