in surefire-booter/src/main/java/org/apache/maven/surefire/booter/stream/CommandDecoder.java [75:125]
public Command decode(@Nonnull Memento memento) throws IOException, MalformedChannelException {
try {
MasterProcessCommand commandType = readMessageType(memento);
if (commandType == null) {
throw new MalformedFrameException(
memento.getLine().getPositionByteBuffer(),
memento.getByteBuffer().position());
}
for (SegmentType segmentType : nextSegmentType(commandType)) {
switch (segmentType) {
case STRING_ENCODING:
memento.setCharset(readCharset(memento));
break;
case DATA_STRING:
memento.getData().add(readString(memento));
break;
case DATA_INTEGER:
memento.getData().add(readInteger(memento));
break;
case END_OF_FRAME:
memento.getLine()
.setPositionByteBuffer(memento.getByteBuffer().position());
memento.getLine().clear();
return toMessage(commandType, memento);
default:
memento.getLine().setPositionByteBuffer(NO_POSITION);
arguments.dumpStreamText(
"Unknown enum (" + SegmentType.class.getSimpleName() + ") " + segmentType);
}
}
} catch (MalformedFrameException e) {
if (e.hasValidPositions()) {
int length = e.readTo() - e.readFrom();
memento.getLine().write(memento.getByteBuffer(), e.readFrom(), length);
}
return null;
} catch (RuntimeException e) {
getArguments().dumpStreamException(e);
return null;
} catch (IOException e) {
if (!(e.getCause() instanceof InterruptedException)) {
printRemainingStream(memento);
}
throw e;
} finally {
memento.reset();
}
throw new MalformedChannelException();
}