Skip to content

Commit

Permalink
GH-8852: Fix TcpNetServerConnectionFactory.run loop
Browse files Browse the repository at this point in the history
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 0b60dfc)
  • Loading branch information
artembilan committed Jan 5, 2024
1 parent 383361a commit 0f402ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -116,7 +116,7 @@ public void run() {
}
try {
setupServerSocket();
while (true) {
while (isActive()) {
acceptConnectionAndExecute();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -222,12 +222,6 @@ public void testObtainConnectionIds(AbstractServerConnectionFactory serverFactor
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);
Expand Down

0 comments on commit 0f402ca

Please sign in to comment.