Skip to content

Commit 47d2527

Browse files
fixing switch with class issue
1 parent 575ece4 commit 47d2527

File tree

1 file changed

+7
-5
lines changed
  • x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/telemetry

1 file changed

+7
-5
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/telemetry/InferenceStats.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ public static Map<String, Object> responseAttributes(@Nullable Throwable t) {
8181
}
8282

8383
private static Stream<Map.Entry<String, Object>> errorAttributes(@Nullable Throwable t) {
84-
return switch (t) {
85-
case null -> Stream.of(entry("status_code", 200));
86-
case ElasticsearchStatusException ese -> Stream.<Map.Entry<String, Object>>builder()
84+
if (t == null) {
85+
return Stream.of(entry("status_code", 200));
86+
} else if (t instanceof ElasticsearchStatusException ese) {
87+
return Stream.<Map.Entry<String, Object>>builder()
8788
.add(entry("status_code", ese.status().getStatus()))
8889
.add(entry("error.type", String.valueOf(ese.status().getStatus())))
8990
.build();
90-
default -> Stream.of(entry("error.type", t.getClass().getSimpleName()));
91-
};
91+
} else {
92+
return Stream.of(entry("error.type", t.getClass().getSimpleName()));
93+
}
9294
}
9395
}

0 commit comments

Comments
 (0)