This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch surefire-3.5.x
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/surefire-3.5.x by this push:
new dadd55b7a Issue #2613 Debugging failsafe tests: Message 'Listening for
transport dt_socket at address' is not displayed anymore when using
maven.surefire.debug (#3353) (#3354)
dadd55b7a is described below
commit dadd55b7a6a3a0336c253413f68c4f08092328c2
Author: Olivier Lamy <[email protected]>
AuthorDate: Tue May 19 07:01:48 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) (#3354)
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 f687a262d..7985cb214 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
@@ -112,9 +112,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));
}