Cherry-picked from #48957 Co-authored-by: LiBinfeng <libinfeng@selectdb.com>
This commit is contained in:
committed by
GitHub
parent
1822120c13
commit
13c174df4b
@ -84,7 +84,7 @@ public class StringArithmetic {
|
||||
if (stringLength == 0) {
|
||||
return "";
|
||||
}
|
||||
int leftIndex = 0;
|
||||
long leftIndex = 0;
|
||||
if (second < (- stringLength)) {
|
||||
return "";
|
||||
} else if (second < 0) {
|
||||
@ -94,7 +94,7 @@ public class StringArithmetic {
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
int rightIndex = 0;
|
||||
long rightIndex = 0;
|
||||
if (third <= 0) {
|
||||
return "";
|
||||
} else if ((third + leftIndex) > stringLength) {
|
||||
@ -102,7 +102,8 @@ public class StringArithmetic {
|
||||
} else {
|
||||
rightIndex = third + leftIndex;
|
||||
}
|
||||
return first.substring(leftIndex, rightIndex);
|
||||
// left index and right index are in integer range because of definition, so we can safely cast it to int
|
||||
return first.substring((int) leftIndex, (int) rightIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user