Skip to content

Commit

Permalink
Ensure that Jetty is completely stopped when it fails to start
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Apr 3, 2018
1 parent 399455f commit 30de75c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -155,9 +155,11 @@ public void start() throws EmbeddedServletContainerException {
.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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,16 @@ public void destroy() {

});
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
Expand Down

0 comments on commit 30de75c

Please sign in to comment.