Skip to content

Commit

Permalink
Add check on length before substring
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed Feb 7, 2024
1 parent 909a19c commit 051f0f4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ public static Map<String, Integer> limitKeySize(Map<String, Integer> axisMap) {
boolean hasEqual = false;
// Let first check if the proposed key is a leading substring of another key
for (String innerKey : axisMap.keySet()) {// Check if this key will be equal to any future keys.
hasEqual = key.substring(0, MAX_X_LABEL_LINE_LENGTH).equals(innerKey.substring(0, MAX_X_LABEL_LINE_LENGTH));
if (hasEqual) {
break;
if (innerKey.length() >= MAX_X_LABEL_LINE_LENGTH) {
hasEqual = key.substring(0, MAX_X_LABEL_LINE_LENGTH).equals(innerKey.substring(0, MAX_X_LABEL_LINE_LENGTH));
if (hasEqual) {
break;
}
}
}

Expand Down

0 comments on commit 051f0f4

Please sign in to comment.