GH-8852: Fix TcpNetServerConnectionFactory.run loop

Fixes: #8852

The `while (true) {` causes the thread to be blocked forever.
The `stop()` waits on the `if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) {` the whole time

* Fix with the `while (isActive()) {`
* Remove the `ConnectionFactoryTests.testEarlyCloseNet()` since we cannot reach expectations because of
race condition between `start()` and `stop()`

**Cherry-pick to `6.2.x` & `6.1.x`**

(cherry picked from commit 0b60dfc9d1)
This commit is contained in:
Artem Bilan
2024-01-05 15:53:37 -05:00
parent 383361a32a
commit 0f402ca2e6
2 changed files with 3 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,7 +116,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
}
try {
setupServerSocket();
while (true) {
while (isActive()) {
acceptConnectionAndExecute();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -222,12 +222,6 @@ public class ConnectionFactoryTests {
scheduler.shutdown();
}
@Test
public void testEarlyCloseNet() throws Exception {
AbstractServerConnectionFactory factory = new TcpNetServerConnectionFactory(0);
testEarlyClose(factory, "serverSocket", " stopped before accept");
}
@Test
public void testEarlyCloseNio() throws Exception {
AbstractServerConnectionFactory factory = new TcpNioServerConnectionFactory(0);