From cd8f4b672fca3e9db7e3c07376b81084523b08d9 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 21 May 2021 15:31:03 +0100 Subject: [PATCH] Fix NPE on errors without a path Errors that originate from GraphQL itself don't seem to have a path. --- .../graphql/boot/actuate/metrics/GraphQlTags.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQlTags.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQlTags.java index c88007fe..5849e81f 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQlTags.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQlTags.java @@ -27,6 +27,8 @@ import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchPar import graphql.schema.GraphQLObjectType; import io.micrometer.core.instrument.Tag; +import org.springframework.util.CollectionUtils; + /** * Factory methods for Tags associated with a GraphQL requests. * @@ -60,7 +62,7 @@ public final class GraphQlTags { public static Tag errorPath(GraphQLError error) { StringBuilder builder = new StringBuilder(); List pathSegments = error.getPath(); - if (!pathSegments.isEmpty()) { + if (!CollectionUtils.isEmpty(pathSegments)) { builder.append('$'); for (Object segment : pathSegments) { try {