Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when integrate with micrometer-tracing and webflux #577

Closed
neo7343 opened this issue Dec 13, 2022 · 1 comment
Closed

NPE when integrate with micrometer-tracing and webflux #577

neo7343 opened this issue Dec 13, 2022 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@neo7343
Copy link

neo7343 commented Dec 13, 2022

simple setup using start.spring.io setup

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.0.0'
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-graphql'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'io.micrometer:micrometer-tracing-bridge-brave'
    implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.graphql:spring-graphql-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

schema

type Query {
    hello: String!
}

controller

@Controller
public class QueryController {
    @QueryMapping
    public String hello(){
        return "hello world";
    }
}

request

curl --location --request POST 'http://localhost:8080/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{hello}"}'

then got this error

java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.Map.get(Object)" is null
	at org.springframework.graphql.observation.ExecutionRequestObservationContext.lambda$new$0(ExecutionRequestObservationContext.java:35) ~[spring-graphql-1.1.0.jar:1.1.0]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ org.springframework.web.filter.reactive.ServerHttpObservationFilter [DefaultWebFilterChain]
	*__checkpoint ⇢ HTTP POST "/graphql" [ExceptionHandlingWebHandler]
Original Stack Trace:
		at org.springframework.graphql.observation.ExecutionRequestObservationContext.lambda$new$0(ExecutionRequestObservationContext.java:35) ~[spring-graphql-1.1.0.jar:1.1.0]
		at io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler.lambda$onStart$0(PropagatingReceiverTracingObservationHandler.java:59) ~[micrometer-tracing-1.0.0.jar:1.0.0]
		at io.micrometer.tracing.brave.bridge.W3CPropagation.lambda$extractor$1(W3CPropagation.java:249) ~[micrometer-tracing-bridge-brave-1.0.0.jar:1.0.0]
		at io.micrometer.tracing.brave.bridge.BravePropagator.extract(BravePropagator.java:59) ~[micrometer-tracing-bridge-brave-1.0.0.jar:1.0.0]
		at io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler.onStart(PropagatingReceiverTracingObservationHandler.java:58) ~[micrometer-tracing-1.0.0.jar:1.0.0]
		at io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler.onStart(PropagatingReceiverTracingObservationHandler.java:35) ~[micrometer-tracing-1.0.0.jar:1.0.0]
		at io.micrometer.observation.ObservationHandler$FirstMatchingCompositeObservationHandler.lambda$onStart$1(ObservationHandler.java:134) ~[micrometer-observation-1.10.2.jar:1.10.2]
		at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
		at io.micrometer.observation.ObservationHandler$FirstMatchingCompositeObservationHandler.onStart(ObservationHandler.java:134) ~[micrometer-observation-1.10.2.jar:1.10.2]
		at io.micrometer.observation.SimpleObservation.lambda$notifyOnObservationStarted$2(SimpleObservation.java:188) ~[micrometer-observation-1.10.2.jar:1.10.2]
		at java.base/java.util.ArrayDeque.forEach(ArrayDeque.java:888) ~[na:na]
		at io.micrometer.observation.SimpleObservation.notifyOnObservationStarted(SimpleObservation.java:188) ~[micrometer-observation-1.10.2.jar:1.10.2]
		at io.micrometer.observation.SimpleObservation.start(SimpleObservation.java:143) ~[micrometer-observation-1.10.2.jar:1.10.2]
		at org.springframework.graphql.observation.GraphQlObservationInstrumentation.beginExecution(GraphQlObservationInstrumentation.java:105) ~[spring-graphql-1.1.0.jar:1.1.0]
		at graphql.execution.instrumentation.ChainedInstrumentation.lambda$beginExecution$0(ChainedInstrumentation.java:85) ~[graphql-java-19.2.jar:na]
		at graphql.collect.ImmutableKit.mapAndDropNulls(ImmutableKit.java:107) ~[graphql-java-19.2.jar:na]
		at graphql.execution.instrumentation.ChainedInstrumentation.beginExecution(ChainedInstrumentation.java:83) ~[graphql-java-19.2.jar:na]
		at graphql.GraphQL.executeAsync(GraphQL.java:522) ~[graphql-java-19.2.jar:na]
		at org.springframework.graphql.execution.DefaultExecutionGraphQlService.lambda$execute$2(DefaultExecutionGraphQlService.java:82) ~[spring-graphql-1.1.0.jar:1.1.0]
		at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:47) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:158) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2034) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:145) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[reactor-core-3.5.0.jar:3.5.0]
		at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:413) ~[reactor-netty-core-1.1.0.jar:1.1.0]
		at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:426) ~[reactor-netty-core-1.1.0.jar:1.1.0]
		at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:603) ~[reactor-netty-http-1.1.0.jar:1.1.0]
		at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:113) ~[reactor-netty-core-1.1.0.jar:1.1.0]
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.85.Final.jar:4.1.85.Final]
		at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.85.Final.jar:4.1.85.Final]
		at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.85.Final.jar:4.1.85.Final]
		at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:266) ~[reactor-netty-http-1.1.0.jar:1.1.0]
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 13, 2022
@bclozel
Copy link
Member

bclozel commented Dec 13, 2022

Duplicates #547

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants