This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/master by this push:
new cd528f9b8 Issue #2613 Debugging failsafe tests: Message 'Listening for
transport dt_socket at address' is not displayed anymore when using
maven.surefire.debug (#3353)
cd528f9b8 is described below
commit cd528f9b8b22547ac95de437671ad21d128dc4fb
Author: Olivier Lamy <[email protected]>
AuthorDate: Mon May 18 20:47:06 2026 +1000
Issue #2613 Debugging failsafe tests: Message 'Listening for transport
dt_socket at address' is not displayed anymore when using maven.surefire.debug
(#3353)
Signed-off-by: Olivier Lamy <[email protected]>
---
.../surefire/api/stream/AbstractStreamDecoder.java | 25 +++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git
a/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
b/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
index 349a71b1b..aed410ce5 100644
---
a/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
+++
b/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoder.java
@@ -111,9 +111,28 @@ protected void debugStream(byte[] array, int position, int
remaining) {}
protected MT readMessageType(@Nonnull Memento memento) throws IOException,
MalformedFrameException {
byte[] header = getEncodedMagicNumber();
- int readCount = DELIMITER_LENGTH + header.length + DELIMITER_LENGTH +
BYTE_LENGTH + DELIMITER_LENGTH;
- read(memento, readCount);
- checkHeader(memento);
+ // Read the header one byte at a time so that non-protocol output
(e.g. the JDWP
+ // "Listening for transport dt_socket at address: ..." line) is
flushed to the console
+ // before the decoder blocks. That line contains ':' which looks like
a frame start;
+ // checking each magic-number byte individually lets us bail out
immediately on a
+ // mismatch instead of stalling on a 24-byte read that never completes.
+ read(memento, DELIMITER_LENGTH);
+ ByteBuffer bb = memento.getByteBuffer();
+ if ((bb.array()[bb.arrayOffset() + bb.position()] & 0xff) != ':') {
+ checkHeader(memento); // not ':', immediately throws
MalformedFrameException
+ }
+ checkDelimiter(memento); // consume the ':'
+ for (int i = 0; i < header.length; i++) {
+ read(memento, DELIMITER_LENGTH);
+ bb = memento.getByteBuffer();
+ if ((bb.array()[bb.arrayOffset() + bb.position()] & 0xff) !=
(header[i] & 0xff)) {
+ // Mismatch: report the ':' plus all bytes read so far in this
frame attempt.
+ throw new
MalformedFrameException(memento.getLine().getPositionByteBuffer(),
bb.position() + 1);
+ }
+ bb.position(bb.position() + 1);
+ }
+ read(memento, DELIMITER_LENGTH);
+ checkDelimiter(memento);
return messageTypes.get(readSegment(memento));
}