spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.92k stars 1.33k forks source link

NPE when using @Query annotation [DATAES-761] #1335

Closed spring-projects-issues closed 4 years ago

spring-projects-issues commented 4 years ago

Anders Clausen opened DATAES-761 and commented

When using Java 11 & the latest versions of spring boot (2.2.5)/spring data I get a NullPointerException when using the @Query annotation to run a basic Elasticsearch query.

This is how my repository looks:

@Repository
public interface VesselsRepository extends ReactiveCrudRepository<Vessel, String> {

    @Query("\"match\" : {\n" +
            "            \"carrierCode\" : {\n" +
            "                \"query\" : \"?0\",\n" +
            "                \"operator\" : \"and\"\n" +
            "            }\n" +
            "        }")
    Flux<Vessel> findByCarrierCode(String carrierCode);
}

Yes, I know I could just use the method as it is without the annotation but this was a test before a more complex query was being used.

This is the full stacktrace from the call:

2020-03-08 11:25:26.851 DEBUG 18052 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [abafc026-1] HTTP GET "/vessels?carrierCodes=MAEU"2020-03-08 11:25:26.851 DEBUG 18052 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [abafc026-1] HTTP GET "/vessels?carrierCodes=MAEU"2020-03-08 11:25:26.873 DEBUG 18052 --- [ctor-http-nio-3] o.s.w.r.f.s.s.RouterFunctionMapping      : [abafc026-1] Mapped to net.apmoller.crb.ao.microservices.reference.data.vessels.routers.ReferenceDataVesselsRouter$$Lambda$711/0x00000008005f1040@706ad2172020-03-08 11:25:26.980 DEBUG 18052 --- [ctor-http-nio-3] o.s.w.r.f.c.ExchangeFunctions            : [5005af8e] HTTP HEAD http://localhost:9200/2020-03-08 11:25:27.045 DEBUG 18052 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [5005af8e] Response 200 OK2020-03-08 11:25:27.048 DEBUG 18052 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] HTTP POST http://localhost:9200/vessels/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&scroll=1m&search_type=dfs_query_then_fetch&batched_reduce_size=5122020-03-08 11:25:27.053 DEBUG 18052 --- [ctor-http-nio-4] o.s.c.c.CharSequenceEncoder              : [-] Writing "{"query":{"wrapper":{"query":"Im1hdGNoIiA6IHsKICAgICAgICAgICAgImNhcnJpZXJDb2RlCiAgICAgICAgICAgICAgI (truncated)...2020-03-08 11:25:27.082 DEBUG 18052 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] Response 400 BAD_REQUEST2020-03-08 11:25:27.094 DEBUG 18052 --- [ctor-http-nio-4] o.s.c.c.ByteArrayDecoder                 : [-] Read 185 bytes2020-03-08 11:25:27.103 DEBUG 18052 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] HTTP POST http://localhost:9200/_search/scroll2020-03-08 11:25:27.104 DEBUG 18052 --- [ctor-http-nio-4] o.s.c.c.CharSequenceEncoder              : [-] Writing "{"scroll_id":null,"scroll":"1m"}"2020-03-08 11:25:27.121 ERROR 18052 --- [ctor-http-nio-4] n.a.c.o.s.r.c.e.ExceptionUtils           : {"method":"GET","requestUri":"/vessels","status":500,"timestamp":"08-03-2020 11:25:27","message":"Internal Server Error","debugMessage":"The mapper returned a null value.","id":"b987c544-453a-4488-8831-0ca2b433268a"}2020-03-08 11:25:27.122 DEBUG 18052 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [abafc026-1] Resolved [NullPointerException: The mapper returned a null value.] for HTTP GET /vessels2020-03-08 11:25:27.122 ERROR 18052 --- [ctor-http-nio-4] a.w.r.e.AbstractErrorWebExceptionHandler : [abafc026-1]  500 Server Error for HTTP GET "/vessels?carrierCodes=MAEU"
java.lang.NullPointerException: The mapper returned a null value. at java.util.Objects.requireNonNull(Objects.java:246) ~[?:?] Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ Handler net.apmoller.crb.ao.microservices.reference.data.vessels.routers.ReferenceDataVesselsRouter$$Lambda$711/0x00000008005f1040@706ad217 [DispatcherHandler] |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] |_ checkpoint ⇢ HTTP GET "/vessels?carrierCodes=MAEU" [ExceptionHandlingWebHandler]Stack trace: at java.util.Objects.requireNonNull(Objects.java:246) ~[?:?] at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:112) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.EmitterProcessor.drain(EmitterProcessor.java:426) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.EmitterProcessor.onNext(EmitterProcessor.java:268) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:530) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:972) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:242) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1705) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:144) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:203) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:103) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1705) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:419) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:209) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:367) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:363) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:412) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:585) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:90) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [netty-handler-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [netty-codec-4.1.45.Final.jar:4.1.45.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [netty-codec-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.45.Final.jar:4.1.45.Final] at java.lang.Thread.run(Thread.java:834) [?:?]
2020-03-08 11:25:27.134 DEBUG 18052 --- [ctor-http-nio-4] o.s.h.c.j.Jackson2JsonEncoder            : [abafc026-1] Encoding [ApiError(method=GET, requestUri=/vessels, status=500, timestamp=08-03-2020 11:25:27, message=Interna (truncated)...]2020-03-08 11:25:27.148 DEBUG 18052 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] Response 400 BAD_REQUEST2020-03-08 11:25:27.148 DEBUG 18052 --- [ctor-http-nio-4] o.s.c.c.ByteArrayDecoder                 : [-] Read 321 bytes2020-03-08 11:25:27.150 DEBUG 18052 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [abafc026-1] Completed 500 INTERNAL_SERVER_ERROR

Affects: 3.2.5 (Moore SR5)

spring-projects-issues commented 4 years ago

sothawo commented

what do you get if you send the query directly to Elasticsearch, for example using curl:

curl -X "POST" "http://localhost:9200/vessels/_search" \
     -H 'Content-Type: application/json' \
     -d $'{
  "query": {
    "match": {
      "message": {
        "query": "PUT YOUR ARGS HERE",
        "operator": "and"
      }
    }
  },
  "size": 10
}'
spring-projects-issues commented 4 years ago

Anders Clausen commented

Apologies Peter but I noticed I had given my query without the proper field name, so I've just updated my ticket with the correct info. If I run this query:

curl -X "POST" "http://localhost:9200/vessels/_search" \
     -H 'Content-Type: application/json' \
     -d $'{
  "query": {
    "match": {
      "carrierCode": {
        "query": "MAEU",
        "operator": "and"
      }
    }
  },
  "size": 10
}'

I get two results back

spring-projects-issues commented 4 years ago

sothawo commented

Having the field name wrong would not produce an error, but return an empty result.

Ok, so can you check the following (I am trying to narrow down where this error comes up, reactive code is pretty awful to debug):

In the code that calls the repository method, please do a blocking collect:

List<Vessel> list = repository.findByCarrierCode("MAEU").collectList().block();

If this succeeds in producing a list of two elements, then I suspect the error being in the code that processes the returned Flux

spring-projects-issues commented 4 years ago

Anders Clausen commented

I've done what you suggested Peter but it never comes back so that I can inspect the list object. This is the stacktrace I got:

2020-03-08 12:43:24.131 DEBUG 14964 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [fd367d8c-1] HTTP GET "/vessels?carrierCodes=MAEU"2020-03-08 12:43:24.131 DEBUG 14964 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [fd367d8c-1] HTTP GET "/vessels?carrierCodes=MAEU"2020-03-08 12:43:24.154 DEBUG 14964 --- [ctor-http-nio-3] o.s.w.r.f.s.s.RouterFunctionMapping      : [fd367d8c-1] Mapped to net.apmoller.crb.ao.microservices.reference.data.vessels.routers.ReferenceDataVesselsRouter$$Lambda$711/0x00000008005f1040@9b8f6eb2020-03-08 12:43:24.268 DEBUG 14964 --- [ctor-http-nio-3] o.s.w.r.f.c.ExchangeFunctions            : [448a5df7] HTTP HEAD http://localhost:9200/2020-03-08 12:43:24.317 ERROR 14964 --- [ctor-http-nio-3] n.a.c.o.s.r.c.e.ExceptionUtils           : {"method":"GET","requestUri":"/vessels","status":500,"timestamp":"08-03-2020 12:43:24","message":"Internal Server Error","debugMessage":"block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3","id":"f521325d-6121-486b-9d40-1ad47fa93bfd"}2020-03-08 12:43:24.319 DEBUG 14964 --- [ctor-http-nio-3] a.w.r.e.AbstractErrorWebExceptionHandler : [fd367d8c-1] Resolved [IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3] for HTTP GET /vessels2020-03-08 12:43:24.319 ERROR 14964 --- [ctor-http-nio-3] a.w.r.e.AbstractErrorWebExceptionHandler : [fd367d8c-1]  500 Server Error for HTTP GET "/vessels?carrierCodes=MAEU"
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3 at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] |_ checkpoint ⇢ HTTP GET "/vessels?carrierCodes=MAEU" [ExceptionHandlingWebHandler]Stack trace: at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Mono.block(Mono.java:1664) ~[reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at net.apmoller.crb.ao.microservices.reference.data.vessels.services.ReferenceDataVesselsService.getVessels(ReferenceDataVesselsService.java:44) ~[classes/:?] at net.apmoller.crb.ao.microservices.reference.data.vessels.handlers.ReferenceDataVesselsHandler.getVessels(ReferenceDataVesselsHandler.java:67) ~[classes/:?] at org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter.handle(HandlerFunctionAdapter.java:61) ~[spring-webflux-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.web.reactive.DispatcherHandler.invokeHandler(DispatcherHandler.java:161) ~[spring-webflux-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.web.reactive.DispatcherHandler.lambda$handle$1(DispatcherHandler.java:146) ~[spring-webflux-5.2.4.RELEASE.jar:5.2.4.RELEASE] at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:274) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:851) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:203) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2267) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:137) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2075) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1949) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:171) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Mono.subscribe(Mono.java:4110) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:441) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:211) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.Mono.subscribe(Mono.java:4110) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55) [reactor-core-3.3.3.RELEASE.jar:3.3.3.RELEASE] at reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:228) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:465) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:90) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:170) [reactor-netty-0.9.5.RELEASE.jar:0.9.5.RELEASE] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [netty-codec-4.1.45.Final.jar:4.1.45.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [netty-codec-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.45.Final.jar:4.1.45.Final] at java.lang.Thread.run(Thread.java:834) [?:?]
2020-03-08 12:43:24.327 DEBUG 14964 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [448a5df7] Response 200 OK2020-03-08 12:43:24.331 DEBUG 14964 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] HTTP POST http://localhost:9200/vessels/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&scroll=1m&search_type=dfs_query_then_fetch&batched_reduce_size=5122020-03-08 12:43:24.336 DEBUG 14964 --- [ctor-http-nio-4] o.s.c.c.CharSequenceEncoder              : [-] Writing "{"query":{"wrapper":{"query":"Im1hdGNoIiA6IHsKICAgICAgICAgICAgImNhcnJpZXJDb2RlCiAgICAgICAgICAgICAgI (truncated)...2020-03-08 12:43:24.337 DEBUG 14964 --- [ctor-http-nio-3] o.s.h.c.j.Jackson2JsonEncoder            : [fd367d8c-1] Encoding [ApiError(method=GET, requestUri=/vessels, status=500, timestamp=08-03-2020 12:43:24, message=Interna (truncated)...]2020-03-08 12:43:24.347 DEBUG 14964 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] Response 400 BAD_REQUEST2020-03-08 12:43:24.363 DEBUG 14964 --- [ctor-http-nio-3] o.s.w.s.a.HttpWebHandlerAdapter          : [fd367d8c-1] Completed 500 INTERNAL_SERVER_ERROR2020-03-08 12:43:24.364 DEBUG 14964 --- [ctor-http-nio-4] o.s.c.c.ByteArrayDecoder                 : [-] Read 185 bytes2020-03-08 12:43:24.380 DEBUG 14964 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] HTTP POST http://localhost:9200/_search/scroll2020-03-08 12:43:24.382 DEBUG 14964 --- [ctor-http-nio-4] o.s.c.c.CharSequenceEncoder              : [-] Writing "{"scroll_id":null,"scroll":"1m"}"2020-03-08 12:43:24.386 DEBUG 14964 --- [ctor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions            : [-] Response 400 BAD_REQUEST2020-03-08 12:43:24.386 DEBUG 14964 --- [ctor-http-nio-4] o.s.c.c.ByteArrayDecoder                 : [-] Read 321 bytes
spring-projects-issues commented 4 years ago

sothawo commented

Are you using router functions to set up your application? Can you add a @Controller annotated class that uses a @GetMapping method to then access the repository?

In these I can do this blocking call.

 

What I am trying to get to is to find if this error comes from the repository implementation, of from code that processes the returned entities.

Do you have code that does some mapping/transformations on the returned entities which might cause this?

spring-projects-issues commented 4 years ago

sothawo commented

I can reproduce it, that's happening only on @Query annotated methods so no need for you to dig into this further

spring-projects-issues commented 4 years ago

sothawo commented

No error in the library here. But in your query definition in the annotation there are the enclosing { and } missing, it should be like this:

@Repository
public interface VesselsRepository extends ReactiveCrudRepository<Vessel, String> {

    @Query("{\"match\" : {\n" +
            "            \"carrierCode\" : {\n" +
            "                \"query\" : \"?0\",\n" +
            "                \"operator\" : \"and\"\n" +
            "            }\n" +
            "        }}")
    Flux<Vessel> findByCarrierCode(String carrierCode);
}