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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user