Wait for up to 30s for access logs to be written during shutdown

Closes gh-17119
pull/17391/head
Andy Wilkinson 6 years ago
parent 2833f60344
commit df9a6a0f4f

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import io.undertow.Handlers; import io.undertow.Handlers;
import io.undertow.Undertow; import io.undertow.Undertow;
@ -156,10 +157,14 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
try { try {
accessLogReceiver.close(); accessLogReceiver.close();
worker.shutdown(); worker.shutdown();
worker.awaitTermination(30, TimeUnit.SECONDS);
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}; };
} }
catch (IOException ex) { catch (IOException ex) {

@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.EventListener; import java.util.EventListener;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -652,10 +653,14 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
try { try {
this.accessLogReceiver.close(); this.accessLogReceiver.close();
this.worker.shutdown(); this.worker.shutdown();
this.worker.awaitTermination(30, TimeUnit.SECONDS);
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
} }
} }

Loading…
Cancel
Save