You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There will be NoSuchElementException when StompMessage.from() method parses STOMP frame which contains SPACE character in the name or value part in header line.
The main code which caused this issue:
The regex means, ':' and all whitespace characters(space, \t, \n, \r, etc) are not allowed in header lines' name or value part. As a result, reader.hasNext will return false when handle a header line contains SPACE character in name or value part, then reader.skip("\n\n") throws NoSuchElementException.
ERROR
receipt-id:message-12345
content-type:text/plain
content-length:170
message:malformed frame received
Solution
According to the STOMP Protocol Specification 1.2 - Augmented BNF,only CR or LF or ":" is not allowed in header's name or value part, so the PATTERN_HEADER constant should be changed to: private static final Pattern PATTERN_HEADER = Pattern.compile("([^:\\n\\r]+)\\s*:\\s*([^:\\n\\r]+)");
The text was updated successfully, but these errors were encountered:
Problem
There will be NoSuchElementException when StompMessage.from() method parses STOMP frame which contains SPACE character in the name or value part in header line.
The main code which caused this issue:
The regex means, ':' and all whitespace characters(space, \t, \n, \r, etc) are not allowed in header lines' name or value part. As a result,
reader.hasNext
will return false when handle a header line contains SPACE character in name or value part, thenreader.skip("\n\n")
throws NoSuchElementException.In fact, it's reasonable to contain SPACE characters in header's value part, as mentioned in the STOMP Protocol Specification 1.2 - ERROR Frame :
Solution
According to the STOMP Protocol Specification 1.2 - Augmented BNF,only CR or LF or ":" is not allowed in header's name or value part, so the PATTERN_HEADER constant should be changed to:
private static final Pattern PATTERN_HEADER = Pattern.compile("([^:\\n\\r]+)\\s*:\\s*([^:\\n\\r]+)");
The text was updated successfully, but these errors were encountered: