When processing RAW parameters as part of parseQuery a look ahead to the next char is needed in order to determine the end of the RAW value. The logic to prevent a StringIndexOutOfBoundsException drops the last char when evaluating for next char when the current char (i) is the second to last char of the string.
This becomes an issue when the RAW value ends in ')'
uri = "foo=RAW(ba(r))"
uri.length() = 14
i = 12
uri.charAt(12) = ')'
uri.charAt(13) = ')'
(i < uri.legnth() - 2) = 12 < (14 - 2) = 12 < 12 = false
thus next = "\u0000"
The RAW value now ends satisfying the requirements and the char at index 13 is never read. The resulting parameter is "foo=RAW(ba(r)".
The logic to prevent the index exception should be "(i <= uri.legnth() -2)" or "(i < uri.legnth() - 1)"