Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19443

runtime function 'splitIndex'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Not a Priority
    • Resolution: Invalid
    • None
    • None
    • Table SQL / Runtime
    • None

    Description

      runtime function 'splitIndex' has NPE problem (located in the SqlFunctionUtils class)

       

      NPE version:

      public static String splitIndex(String str, String separator, int index) {
          if (index < 0)

      {         return null;     }
          String[] values = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator);
          if (index >= values.length) {         return null;     }

      else

      {         return values[index];     }
      }

      public static String splitIndex(String str, int character, int index) {
          if (character > 255 || character < 1 || index < 0) {         return null;     }
          String[] values = StringUtils.splitPreserveAllTokens(str, (char) character);
          if (index >= values.length) {         return null;     } else {         return values[index];     }

      }

       

      Fix version:

      public static String splitIndex(String str, String separator, int index) {
          if (index < 0)

      {         return null;     }
          String[] values = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator);
          if (values == null || index >= values.length) {         return null;     }

      else

      {         return values[index];     }
      }

      public static String splitIndex(String str, int character, int index) {
          if (character > 255 || character < 1 || index < 0) {         return null;     }
          String[] values = StringUtils.splitPreserveAllTokens(str, (char) character);
          if (values == null || index >= values.length) {         return null;     } else {         return values[index];     }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mytang0 Mengyang Tang
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: