Details
-
Bug
-
Status: Closed
-
Not a Priority
-
Resolution: Invalid
-
None
-
None
-
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)
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)
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]; }
}