[ 
https://issues.apache.org/jira/browse/FLINK-19443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17204401#comment-17204401
 ] 

Nicholas Jiang commented on FLINK-19443:
----------------------------------------

[~libenchao], if [~mytang0] wouldn't be available to fix this issue, could you 
please assign to me for fix?

> 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: Minor
>
> 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)

Reply via email to