Skip to content
Permalink
Browse files
[Dubbo-8172]Not shuwdown ExecutorService when DefaultFuture. closeCha…
…nnel() (#8188)

* fix 8172

消费者端ExecutorService在运行期间不应该shutdown

* add UT
  • Loading branch information
zhangyz-hd committed Aug 1, 2021
1 parent 46dc478 commit 9c49efeacfd87d2d4409fb000cebd58e1114ec8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
@@ -142,11 +142,6 @@ public static void closeChannel(Channel channel) {
if (channel.equals(entry.getValue())) {
DefaultFuture future = getFuture(entry.getKey());
if (future != null && !future.isDone()) {
ExecutorService futureExecutor = future.getExecutor();
if (futureExecutor != null && !futureExecutor.isTerminated()) {
futureExecutor.shutdownNow();
}

Response disconnectResponse = new Response(future.getId());
disconnectResponse.setStatus(Response.CHANNEL_INACTIVE);
disconnectResponse.setErrorMessage("Channel " +
@@ -158,6 +158,17 @@ public void interruptSend() throws Exception {
Assertions.assertNull(future);
}

@Test
public void testClose() throws Exception {
Channel channel = new MockedChannel();
Request request = new Request(123);
ExecutorService executor = ExtensionLoader.getExtensionLoader(ExecutorRepository.class)
.getDefaultExtension().createExecutorIfAbsent(URL.valueOf("dubbo://127.0.0.1:23456"));
DefaultFuture.newFuture(channel, request, 1000, executor);
DefaultFuture.closeChannel(channel);
Assertions.assertFalse(executor.isTerminated());
}

/**
* mock a default future
*/

0 comments on commit 9c49efe

Please sign in to comment.