Skip to content

Commit 1569d08

Browse files
authored
fixListBug (#541)
* fixListBug Signed-off-by: xinyual <[email protected]> * fixListBug Signed-off-by: xinyual <[email protected]> --------- Signed-off-by: xinyual <[email protected]>
1 parent 1b8d93c commit 1569d08

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/opensearch/agent/tools/PPLTool.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,15 @@ private static void extractSamples(Map<String, Object> sampleSource, Map<String,
559559
for (Map.Entry<String, Object> entry : sampleSource.entrySet()) {
560560
String p = entry.getKey();
561561
Object v = entry.getValue();
562-
while (v instanceof List<?>) {
563-
v = ((List<?>) v).get(0);
562+
563+
while (!Objects.isNull(v) && v instanceof List<?>) {
564+
List<?> listValue = (List<?>) v;
565+
if (!listValue.isEmpty()) {
566+
v = ((List<?>) v).get(0);
567+
} else {
568+
break;
569+
}
570+
564571
}
565572

566573
String fullKey = prefix + p;

0 commit comments

Comments
 (0)