You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jingsong Lee (Jira)" <ji...@apache.org> on 2021/08/03 02:27:00 UTC

[jira] [Reopened] (FLINK-19443) runtime function 'splitIndex'

     [ https://issues.apache.org/jira/browse/FLINK-19443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jingsong Lee reopened FLINK-19443:
----------------------------------

> runtime function 'splitIndex'
> -----------------------------
>
>                 Key: FLINK-19443
>                 URL: https://issues.apache.org/jira/browse/FLINK-19443
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Runtime
>            Reporter: mytang0
>            Priority: Not a Priority
>
> 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 ({color:#FF0000}values == null ||{color} 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 ({color:#FF0000}values == null ||{color} index >= values.length) {
>         return null;
>     } else {
>         return values[index];
>     }
> }



--
This message was sent by Atlassian Jira
(v8.3.4#803005)