Repository navigation
fix(java): bind the launched JVM's debug port to loopback - #1387
Merged
Merged
Conversation
In launch mode the JDI bridge started the JVM with -agentlib:jdwp=...,address=*:<port>, which listens on every network interface, and attached through "localhost" after a short wait. The JVM is now started with address=127.0.0.1:<port> and the bridge attaches to the same literal address. The bridge's free-port probe binds loopback as well, so nothing the bridge opens listens beyond loopback. Attach mode is unchanged. The wildcard dates from the adapter's first commit (abd5dfe). Neither its message nor the code gives a reason for it, and nothing in the repository relies on reaching the launch's port from another machine. Test: an integration case launches through the bridge and compares the JDWP address of the real launch command with the port the JVM announces. It fails on the previous bridge with "*:<port>". The two substitutions, the test and the docs sentence were written by a GPT worker. The manager session changed the port probe, verified the failing-first run and wrote the changelog entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
The fragment was written under a guessed number that an unrelated issue took in the meantime. No source changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Nov 29, 2026
Review findings on the test of the previous commits; no source change. - It took the first output frame for the JVM's JDWP banner, so any line printed ahead of it (for example "Picked up JAVA_TOOL_OPTIONS") failed the test. It now waits for the frame that matches. - It started the bridge with -Djava.net.preferIPv4Stack=true, which production does not pass. The flag is gone and the bridge is started with --owner-pid, as it ships. - The bridge's start is retried when its reserved port is lost, its pipes are drained for its whole life, a client that never connected is not asked to disconnect, and the work directory is removed with retries. Found by a Claude (Opus) review and a Gemini review of the sibling test; written by the GPT worker that wrote the test; verified by the manager session: it still fails on main's bridge with "*:<port>". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
debugmcpdev
marked this pull request as ready for review
November 29, 2026 22:14
debugmcpdev
pushed a commit
that referenced
this pull request
Nov 29, 2026
Brings in the two Java bridge fixes (#1387, #1393). No conflicts; no file of this change is touched by them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
In launch mode the JDI bridge started the JVM with
-agentlib:jdwp=...,address=*:<port>, which listens on every network interface, and then attached throughlocalhost. JDWP has no authentication, so that port should never be reachable from another machine.address=127.0.0.1:<port>.Attach mode is unchanged: it connects to the host and port it is given.
The wildcard dates from the adapter's first commit. Neither its message nor the code gives a reason for it, and nothing in the repository relies on reaching the launch's port from another machine: the Dockerfile exposes other ports, and the remote recipes start their own JVMs for attach.
Test
tests/adapters/java/integration/java-launch-loopback.test.tslaunches through the bridge and compares the JDWP address of the real launch command with the port the JVM announces. On the previous bridge it fails withExpected: "127.0.0.1:<port>",Received: "*:<port>". It starts the bridge the way it ships, and it does not depend on the JVM's banner being the first line the program prints.Verified
JAVA_TOOL_OPTIONSset (an extra banner line).0ed0ce07: 22 of 22 on Windows and on Linux. The commits after it change the test and the changelog entry's name only.Who wrote what
The two substitutions, the test and the docs sentence were written by a GPT worker. The manager session (Claude) changed the port probe, verified the failing-first runs, and wrote the changelog entry and this description.
🤖 Generated with Claude Code
https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs