[
https://issues.apache.org/jira/browse/FLINK-19443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17203628#comment-17203628
]
Benchao Li commented on FLINK-19443:
------------------------------------
[~mytang0] Thanks for reporting this, would you like to fix this?
> 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)