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

WebClient ArrayIndexOutOfBoundsException [SPR-14894] #19460

Closed
spring-projects-issues opened this issue Nov 10, 2016 · 2 comments
Closed

WebClient ArrayIndexOutOfBoundsException [SPR-14894] #19460

spring-projects-issues opened this issue Nov 10, 2016 · 2 comments
Assignees
Labels
in: web status: duplicate

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Nov 10, 2016

Oleg Kovrizhin opened SPR-14894 and commented

Hello All,

I am playing little bit with spring reactive and found some strange behavior:
I have ArrayIndexOutOfBoundsException when I receive more than 924 entities in the client:

Server side:

  @GetMapping("/persons")
@Produces(MediaType.APPLICATION_JSON)
Flux<Person> list() {
     return this.repository.findAll().take(925);
}

Client side:

ReactorClientHttpConnector clientHttpConnector = new ReactorClientHttpConnector();
ClientRequest.HeadersBuilder<?> get = ClientRequest.GET("http://localhost:8080/persons");
Flux<Person> personFlux = WebClient.create(clientHttpConnector).retrieveFlux(get.build(), Person.class);
System.out.println(personFlux.toStream().count());

Stack Trace:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -8236
at io.netty.buffer.HeapByteBufUtil.getByte(HeapByteBufUtil.java:24)
at io.netty.buffer.UnpooledHeapByteBuf._getByte(UnpooledHeapByteBuf.java:323)
at io.netty.buffer.UnpooledHeapByteBuf.getByte(UnpooledHeapByteBuf.java:318)
at org.springframework.http.codec.json.JsonObjectDecoder$1.apply(JsonObjectDecoder.java:140)
at org.springframework.http.codec.json.JsonObjectDecoder$1.apply(JsonObjectDecoder.java:103)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:353)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.onNext(FluxSubscribeOn.java:148)
at reactor.ipc.netty.common.NettyChannelHandler$InboundSink.drain(NettyChannelHandler.java:707)
at reactor.ipc.netty.common.NettyChannelHandler$InboundSink.next(NettyChannelHandler.java:616)
at reactor.ipc.netty.common.NettyChannelHandler.doRead(NettyChannelHandler.java:134)
at reactor.ipc.netty.http.NettyHttpClientHandler.channelRead(NettyHttpClientHandler.java:133)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:651)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:574)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:488)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:450)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at java.lang.Thread.run(Thread.java:745)

gradle:
compile "org.springframework:spring-core:5.0.0.M3"
compile "org.springframework:spring-web:5.0.0.M3"
compile "org.springframework:spring-web-reactive:5.0.0.M3"
compile "io.netty:netty-all:4.1.6.Final"
compile "io.projectreactor.ipc:reactor-netty:0.5.2.RELEASE"

Then I decriese count of produced entity, all works fine, and I recieved all entities.

Best regards,
Oleg


Affects: 5.0 M3

Issue Links:

  • #19580 JsonObjectDecoder throws ArrayIndexOutOfBoundsException: -1 with valid input ("duplicates")
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 14, 2016

Brian Clozel commented

Hi Oleg Kovrizhin,

There have been a few changes in reactor-netty lately, including fixing issues on flushing full buffers in Netty (which looks a lot like this issue).
Could you try again with SNAPSHOTs versions?

gradle:
compile "org.springframework:spring-core:5.0.0.BUILD-SNAPSHOT"
compile "org.springframework:spring-web:5.0.0.BUILD-SNAPSHOT"
compile "org.springframework:spring-web-reactive:5.0.0.BUILD-SNAPSHOT"
compile "io.netty:netty-all:4.1.6.Final"
compile "io.projectreactor.ipc:reactor-netty:0.6.0.BUILD-SNAPSHOT"

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 14, 2016

Sébastien Deleuze commented

I have just fixed it via #19580, please check again with latest snapshot it should be fine now. If not please re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web status: duplicate
Projects
None yet
Development

No branches or pull requests

2 participants