diff --git a/core/src/main/java/com/linecorp/armeria/common/ContextAwareBlockingTaskExecutor.java b/core/src/main/java/com/linecorp/armeria/common/ContextAwareBlockingTaskExecutor.java index 7e0821eb829..ee1f7bda875 100644 --- a/core/src/main/java/com/linecorp/armeria/common/ContextAwareBlockingTaskExecutor.java +++ b/core/src/main/java/com/linecorp/armeria/common/ContextAwareBlockingTaskExecutor.java @@ -28,7 +28,7 @@ public interface ContextAwareBlockingTaskExecutor extends BlockingTaskExecutor, ContextAwareScheduledExecutorService { /** - * Returns a new {@link ContextAwareEventLoop} that sets the specified {@link RequestContext} + * Returns a new {@link ContextAwareBlockingTaskExecutor} that sets the specified {@link RequestContext} * before executing any submitted tasks. */ static ContextAwareBlockingTaskExecutor of(RequestContext context, BlockingTaskExecutor executor) { diff --git a/core/src/main/java/com/linecorp/armeria/server/DefaultServerConfig.java b/core/src/main/java/com/linecorp/armeria/server/DefaultServerConfig.java index 357b319d727..9540d092a06 100644 --- a/core/src/main/java/com/linecorp/armeria/server/DefaultServerConfig.java +++ b/core/src/main/java/com/linecorp/armeria/server/DefaultServerConfig.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import java.util.concurrent.ScheduledExecutorService; import java.util.function.Function; import java.util.function.Predicate; @@ -677,7 +676,7 @@ static String toString( long http2MaxHeaderListSize, long http1MaxInitialLineLength, long http1MaxHeaderSize, long http1MaxChunkSize, int proxyProtocolMaxTlvSize, Duration gracefulShutdownQuietPeriod, Duration gracefulShutdownTimeout, - @Nullable ScheduledExecutorService blockingTaskExecutor, + @Nullable BlockingTaskExecutor blockingTaskExecutor, @Nullable MeterRegistry meterRegistry, Map, ?> channelOptions, Map, ?> childChannelOptions, List clientAddressSources, diff --git a/core/src/test/java/com/linecorp/armeria/server/ServiceBindingBuilderTest.java b/core/src/test/java/com/linecorp/armeria/server/ServiceBindingBuilderTest.java index 66151c28ee6..8d3aa529572 100644 --- a/core/src/test/java/com/linecorp/armeria/server/ServiceBindingBuilderTest.java +++ b/core/src/test/java/com/linecorp/armeria/server/ServiceBindingBuilderTest.java @@ -40,6 +40,7 @@ import com.linecorp.armeria.common.HttpMethod; import com.linecorp.armeria.common.HttpRequest; import com.linecorp.armeria.common.HttpResponse; +import com.linecorp.armeria.common.util.BlockingTaskExecutor; import com.linecorp.armeria.common.util.UnmodifiableFuture; import com.linecorp.armeria.server.logging.AccessLogWriter; @@ -50,7 +51,7 @@ public void serviceBindingBuilder() { final ServerBuilder sb = Server.builder(); final AccessLogWriter accessLogWriter = mock(AccessLogWriter.class); when(accessLogWriter.shutdown()).thenReturn(UnmodifiableFuture.completedFuture(null)); - final ScheduledExecutorService blockingTaskExecutor = mock(ScheduledExecutorService.class); + final BlockingTaskExecutor blockingTaskExecutor = mock(BlockingTaskExecutor.class); when(blockingTaskExecutor.isTerminated()).thenReturn(true); final Path multipartUploadsLocation = Files.newTemporaryFolder().toPath(); diff --git a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/ArmeriaThreadPool.java b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/ArmeriaThreadPool.java index b306e46a124..52a93379592 100644 --- a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/ArmeriaThreadPool.java +++ b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/ArmeriaThreadPool.java @@ -16,14 +16,14 @@ package com.linecorp.armeria.server.jetty; -import java.util.concurrent.ScheduledExecutorService; - import org.eclipse.jetty.util.thread.ThreadPool; +import com.linecorp.armeria.common.util.BlockingTaskExecutor; + final class ArmeriaThreadPool implements ThreadPool { - private final ScheduledExecutorService blockingTaskExecutor; + private final BlockingTaskExecutor blockingTaskExecutor; - ArmeriaThreadPool(ScheduledExecutorService blockingTaskExecutor) { + ArmeriaThreadPool(BlockingTaskExecutor blockingTaskExecutor) { this.blockingTaskExecutor = blockingTaskExecutor; } diff --git a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyService.java b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyService.java index 72f9eabb641..412c0a91481 100644 --- a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyService.java +++ b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyService.java @@ -24,7 +24,6 @@ import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.Arrays; -import java.util.concurrent.ScheduledExecutorService; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -60,6 +59,7 @@ import com.linecorp.armeria.common.ResponseHeaders; import com.linecorp.armeria.common.ResponseHeadersBuilder; import com.linecorp.armeria.common.annotation.Nullable; +import com.linecorp.armeria.common.util.BlockingTaskExecutor; import com.linecorp.armeria.common.util.CompletionActions; import com.linecorp.armeria.common.util.Exceptions; import com.linecorp.armeria.internal.server.servlet.ServletTlsAttributes; @@ -166,7 +166,7 @@ public static JettyServiceBuilder builder() { return new JettyServiceBuilder(); } - private final Function serverFactory; + private final Function serverFactory; private final Consumer postStopTask; private final Configurator configurator; @@ -182,13 +182,13 @@ public static JettyServiceBuilder builder() { private boolean startedServer; private JettyService(@Nullable String hostname, boolean tlsReverseDnsLookup, - Function serverSupplier) { + Function serverSupplier) { this(hostname, tlsReverseDnsLookup, serverSupplier, unused -> { /* unused */ }); } JettyService(@Nullable String hostname, boolean tlsReverseDnsLookup, - Function serverFactory, + Function serverFactory, Consumer postStopTask) { this.hostname = hostname; diff --git a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyServiceBuilder.java b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyServiceBuilder.java index aba90437cbb..c5e308f975e 100644 --- a/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyServiceBuilder.java +++ b/jetty9/src/main/java/com/linecorp/armeria/server/jetty/JettyServiceBuilder.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import java.util.concurrent.ScheduledExecutorService; import java.util.function.Consumer; import java.util.function.Function; @@ -38,6 +37,7 @@ import com.google.common.collect.ImmutableMap; import com.linecorp.armeria.common.annotation.Nullable; +import com.linecorp.armeria.common.util.BlockingTaskExecutor; /** * Builds a {@link JettyService}. Use {@link JettyService#of(Server)} if you have a configured Jetty @@ -271,7 +271,7 @@ public JettyService build() { final List lifeCycleListeners = this.lifeCycleListeners.build(); final List> customizers = this.customizers.build(); - final Function serverFactory = blockingTaskExecutor -> { + final Function serverFactory = blockingTaskExecutor -> { final Server server = new Server(new ArmeriaThreadPool(blockingTaskExecutor)); if (dumpAfterStart != null) {