Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run client connection handler inside new thread, fixes #798 #801

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/early-access.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions daemon/src/main/java/org/mvndaemon/mvnd/daemon/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,16 @@ private void accept() {
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) {
Expand Down Expand Up @@ -270,7 +279,7 @@ private void client(SocketChannel socket) {
updateState(DaemonState.Idle);
return;
}
LOGGER.info("Request received: " + message);
LOGGER.info("Request received: {}", message);
psiroky marked this conversation as resolved.
Show resolved Hide resolved
if (message instanceof BuildRequest) {
handle(connection, (BuildRequest) message);
}
Expand Down