Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] java.lang.IllegalArgumentException: !utf8 when decode a request containing Thai character


when I try to post any data containing Thai character, Jetty7 will
throw an exception:

java.lang.IllegalArgumentException: !utf8 at
org.eclipse.jetty.util.Utf8StringBuilder.append( at
org.eclipse.jetty.util.UrlEncoded.decodeUtf8To( at
org.eclipse.jetty.util.UrlEncoded.decodeTo( at

It seems Utf8StringBuffer.append() will always throw
java.lang.IllegalArgumentException: !utf8 when try to decode any
unicode character between 2048 to 4095.

To reproduce it, run this code:

public static void main(String[] args) throws Exception {
   UrlEncoded encoded = new UrlEncoded();
   UrlEncoded encoded2 = new UrlEncoded();

   // 2047, 2048, 2049, 4094, 4095, 4096
    String[] characters = {"\u07FF",  "\u0800", "\u0801", "\u0FFE",
"\u0FFF", "\u1000"};
    String expectEncoded;
    for (String character : characters) {

      encoded.add("var", character);
      expectEncoded = encoded.encode();
      try {
        System.out.println("PASSED " + (int) character.charAt(0));
      } catch (Exception e) {
        System.out.println("FAILED " + (int) character.charAt(0) + ",
" + e.getMessage());

Am I missing something?  Or is it a Jetty7 bug?

Thanks in advance,

Back to the top