Skip to content

Commit

Permalink
[Dubbo-8172]Not shuwdown ExecutorService when DefaultFuture. closeCha…
Browse files Browse the repository at this point in the history
…nnel() (#8188)

* fix 8172

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

* add UT
  • Loading branch information
zhangyz-hd committed Aug 1, 2021
1 parent 46dc478 commit 9c49efe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -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 " +
Expand Down
Expand Up @@ -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
*/
Expand Down

0 comments on commit 9c49efe

Please sign in to comment.