Skip to content

Commit

Permalink
DropwizardTestSupport: after() completes even if before() failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Kimbrough committed Apr 9, 2015
1 parent 252943e commit d7c262c
Showing 1 changed file with 17 additions and 11 deletions.
Expand Up @@ -72,20 +72,26 @@ public void before() {
}

public void after() {
for (ServiceListener<C> listener : listeners) {
stopIfRequired();
resetConfigOverrides();
}

private void stopIfRequired() {
if( jettyServer != null) {
for (ServiceListener<C> listener : listeners) {
try {
listener.onStop(this);
} catch (Exception ignored) {
}
}
try {
listener.onStop(this);
} catch (Exception ignored) {
jettyServer.stop();
} catch (Exception e) {
throw propagate(e);
} finally {
jettyServer = null;
}
}
resetConfigOverrides();
try {
jettyServer.stop();
} catch (Exception e) {
throw propagate(e);
} finally {
jettyServer = null;
}
}

private void applyConfigOverrides() {
Expand Down

0 comments on commit d7c262c

Please sign in to comment.