Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4408

Some unicode characters can't be parsed with Thrift Java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0, 0.11.0
    • None
    • Java - Compiler
    • None
    • Patch Available

    Description

      If string field of thrift object contains character

      encoded as "\uff1c then parser can't parse such object at all and fails with:

      java.lang.IllegalArgumentException: -228
      
      	at java.lang.String.<init>(String.java:266)
      	at org.apache.thrift.protocol.TJSONProtocol.readJSONString(TJSONProtocol.java:691)
      

      Here the unit test to reproduce it:

      @Test
          public void readUnicode_uff1c() throws Exception {
              String jsonEncodedEntity = "{\"1\":{\"str\":\"\\uff1c\"}}";
              byte[] bytesEntity = jsonEncodedEntity.getBytes();
      
              TMemoryBuffer memoryBuffer = new TMemoryBuffer(bytesEntity.length);
              memoryBuffer.write(bytesEntity);
              memoryBuffer.close();
      
              TJSONProtocol protocol = new TJSONProtocol(memoryBuffer);
              protocol.readStructBegin();
              protocol.readFieldBegin();
              assertEquals("<", protocol.readString());
          }
      

      Attachments

        1. thrift_unicode_patch.patch
          2 kB
          Sergey Krutsko

        Activity

          People

            Unassigned Unassigned
            skrutsko Sergey Krutsko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: