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

Is there a reason why hexVal() in TJSONProtocol.java throws exception when uppercase alphabet is given?

    XMLWordPrintableJSON

    Details

    • Type: Question
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Found out that passing unicode string "\uB300\uCE58" to Java server causes "Expected hex character" in lib/java/src/protocol/TJSONProtocol.java:306.

      TJSONProtocol.java
      // Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its
      // corresponding hex value
      private static final byte hexVal(byte ch) throws TException {
          if ((ch >= '0') && (ch <= '9')) {
              return (byte)((char)ch - '0');
          }
          else if ((ch >= 'a') && (ch <= 'f')) {
              return (byte)((char)ch - 'a');
          }
          else {
              throw new TProtocolException(TProtocolException.INVALID_DATA,
                                          "Expected hex character");
          }
      }

      This is due to alphabet 'B' is not between '0' ~ '9' or 'a' ~ 'f'.
      Not that it's causing major issues or anything, just curious if the if~ else conditionals are set like this for a reason.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              arfarf89 Chae Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: