From 4b58495a0837c3ea2c1c8dfcdb8a5f659290c32c Mon Sep 17 00:00:00 2001 From: naomichi-y Date: Tue, 23 Apr 2024 00:52:57 +0900 Subject: [PATCH] Fixed bug in path.lastIndexOf() Signed-off-by: naomichi-y --- .../common/xcontent/JsonToStringXContentParser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java b/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java index a4543a4ac6bef..998122d9e5c43 100644 --- a/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java +++ b/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java @@ -106,7 +106,7 @@ private void parseToken(StringBuilder path, String currentFieldName) throws IOEx // skip } else if (this.parser.currentToken() == Token.START_OBJECT) { parseToken(path, currentFieldName); - int dotIndex = path.lastIndexOf(DOT_SYMBOL); + int dotIndex = path.lastIndexOf(DOT_SYMBOL, path.length()); if (dotIndex != -1 && path.length() > currentFieldName.length()) { path.setLength(path.length() - currentFieldName.length() - 1); @@ -118,7 +118,7 @@ private void parseToken(StringBuilder path, String currentFieldName) throws IOEx parseValue(parsedFields); this.valueList.add(parsedFields.toString()); this.valueAndPathList.add(path + EQUAL_SYMBOL + parsedFields); - int dotIndex = path.lastIndexOf(DOT_SYMBOL); + int dotIndex = path.lastIndexOf(DOT_SYMBOL, path.length()); if (dotIndex != -1 && path.length() > currentFieldName.length()) { path.setLength(path.length() - currentFieldName.length() - 1); }