…raming (microsoft#653)
* fix: harden debug session loopback binding, auth handshake, and DAP framing
- Replace the shared wildcard debug server socket with per-session loopback
(127.0.0.1) server sockets, a 256-bit JavaDebug-Auth handshake with
constant-time verification, single-client socket closure, and an unused
session timeout reaper (protocolVersion >= 2 via startDebugSession).
- Enforce initialize lifecycle gating in DebugAdapter before request
argument deserialization, guard AttachRequestHandler against uninitialized
contexts, and prevent self-PID termination in DebuggeeProcessHelper.
- Slice inbound Content-Length frames by UTF-8 byte length rather than UTF-16
character count in AbstractProtocolServer, with header and body size bounds.
- Bind JDI launch listening sockets strictly to 127.0.0.1 via
LoopbackSocketListeningConnector with debugger-first JDWP-Handshake
validation and guaranteed stopListening cleanup across launch error paths.
- Add unit and OSGi end-to-end regression tests covering authentication,
framing, initialization gating, loopback JDI listening, launch,
oDebug,
and �ttach flows.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* test: handle TCP reset when server closes rejected sockets on macOS
On BSD/macOS kernels, closing a socket while unread client bytes remain in
SO_RCVBUF sends a TCP RST (SocketException: Connection reset) rather than a
FIN (-1 EOF). Accept either EOF or SocketException after connect when verifying
that unauthenticated or invalid-token sockets are closed without emitting any
DAP response.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* fix: bound JDWP packet length, handshake deadline, and rejected listener cleanup
- Enforce an upper JDWP packet-size bound (64 MiB default) in
LoopbackSocketConnection.readPacket() and close the connection before
allocating oversized buffers.
- Enforce an absolute wall-clock deadline across performJdwpHandshake() reads
so slow-drip peers cannot stretch per-read SO_TIMEOUT.
- Remove and close session listeners when executor submission throws in
startDebugSession() and startLegacyLoopbackSession().
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* fix(plugin): isolate session pools, bound auth deadline, and serialize JDWP I/O
Separate listener, handshake, and session worker pools with per-listener candidate permits, enforce an absolute authentication handshake deadline across reads, and serialize JDWP socket packet reads and writes while preserving mid-packet EOF errors.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* fix(plugin): bound launch failure cleanup and async test javac drain
Close the JDWP listener immediately on launch failure, drain debuggee stdout/stderr asynchronously with bounded timeouts while terminating the child process, and drain javac output asynchronously in end-to-end test compilation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* fix: complete launch future only from winning outcome handler
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* feat: add JDWP handshake usage telemetry and handshake timeout overrides
Record structured `jdwp handshake` usage telemetry (`outcome`, `duration`, `timeoutMs`)
inside `LoopbackSocketListeningConnector.performJdwpHandshake` and allow overriding
the 5-second DAP and JDWP handshake timeouts via `java.debug.dap.handshakeTimeoutMs`
and `java.debug.jdwp.handshakeTimeoutMs` system properties.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>