This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch mvnd-0.10.x
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
The following commit(s) were added to refs/heads/mvnd-0.10.x by this push:
new 8af598ee Run client connection handler inside new thread, fixes #798
(#799)
8af598ee is described below
commit 8af598ee231d447572dc6a3b0fe7e4b0ed72b2a0
Author: Petr Široký <[email protected]>
AuthorDate: Tue Mar 7 14:15:37 2023 +0100
Run client connection handler inside new thread, fixes #798 (#799)
* Run client connection handler inside new thread, fixes #798
* Execute CI build on ubuntu-22.04
---
.github/workflows/early-access.yaml | 2 +-
daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/early-access.yaml
b/.github/workflows/early-access.yaml
index 6ea62920..2b4fcc76 100644
--- a/.github/workflows/early-access.yaml
+++ b/.github/workflows/early-access.yaml
@@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ ubuntu-18.04, macOS-10.15, windows-2019 ]
+ os: [ ubuntu-22.04, macOS-10.15, windows-2019 ]
runs-on: ${{ matrix.os }}
steps:
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java
b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java
index 115417cd..be66cbb7 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java
@@ -233,7 +233,16 @@ public class Server implements AutoCloseable, Runnable {
try {
while (true) {
try (SocketChannel socket = this.socket.accept()) {
- client(socket);
+ try {
+ // execute the client connection handling inside a new
thread to guard against possible
+ // ThreadLocal memory leaks
+ // see https://github.com/apache/maven-mvnd/issues/798
for more details
+ Thread handler = new Thread(() -> client(socket));
+ handler.start();
+ handler.join();
+ } catch (Throwable t) {
+ LOGGER.error("Error handling a client connection", t);
+ }
}
}
} catch (Throwable t) {
@@ -264,7 +273,7 @@ public class Server implements AutoCloseable, Runnable {
updateState(DaemonState.Idle);
return;
}
- LOGGER.info("Request received: " + message);
+ LOGGER.info("Request received: {}", message);
if (message instanceof BuildRequest) {
handle(connection, (BuildRequest) message);
}