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

ClientResponse bodyToFlux fails when encoding empty JSON array [SPR-15685] #20244

Closed
spring-projects-issues opened this issue Jun 20, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 20, 2017

Gilberto J Requena opened SPR-15685 and commented

When the web client receives an empty array JSON as response a MismatchedInputException occurs.

In the following project https://github.com/gilbertojrequena/web-reactive-test you can find the example code.

Here the falling test https://github.com/gilbertojrequena/web-reactive-test/blob/master/src/test/java/com/gilbertojrequena/reactive/service/FooServiceTest.java#L37

org.springframework.core.codec.DecodingException: JSON decoding error: No content to map due to end-of-input; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 0]))

	at reactor.test.DefaultStepVerifierBuilder.failPrefix(DefaultStepVerifierBuilder.java:2114)
	at reactor.test.DefaultStepVerifierBuilder.fail(DefaultStepVerifierBuilder.java:2110)
	at reactor.test.DefaultStepVerifierBuilder.lambda$expectComplete$3(DefaultStepVerifierBuilder.java:199)
	at reactor.test.DefaultStepVerifierBuilder$SignalEvent.test(DefaultStepVerifierBuilder.java:1855)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onSignal(DefaultStepVerifierBuilder.java:1241)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onExpectation(DefaultStepVerifierBuilder.java:1186)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onError(DefaultStepVerifierBuilder.java:858)
	at reactor.core.publisher.MonoFlatMapMany$FlatMapInner.onError(MonoFlatMapMany.java:234)
	at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:120)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:104)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:608)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:487)
	at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:896)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:89)
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:54)
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:380)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.ipc.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:207)
	at reactor.ipc.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:322)
	at reactor.ipc.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:316)
	at reactor.ipc.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:581)
	at reactor.ipc.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:125)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at java.lang.Thread.run(Thread.java:748)
	Suppressed: org.springframework.core.codec.DecodingException: JSON decoding error: No content to map due to end-of-input; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 0]
		at org.springframework.http.codec.json.Jackson2JsonDecoder.lambda$decodeInternal$0(Jackson2JsonDecoder.java:124)
		at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100)
		... 38 more
	Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 0]
		at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:58)
		at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1320)
		at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:356)
		at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1598)
		at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)
		at org.springframework.http.codec.json.Jackson2JsonDecoder.lambda$decodeInternal$0(Jackson2JsonDecoder.java:116)
		... 39 more

Affects: 5.0 RC2

Reference URL: https://github.com/gilbertojrequena/web-reactive-test

Attachments:

Referenced from: commits 0a4d3c1

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 21, 2017

Arjen Poutsma commented

Fixed in 0a4d3c1

Thanks for reporting this issue!

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 21, 2017

Gilberto J Requena commented

Thanks for the quick fix :)

@spring-projects-issues spring-projects-issues added type: bug A general bug in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0 RC3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants