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

Exception accessing static resources in Spring Web Reactive with Netty [SPR-14975] #19541

Closed
spring-issuemaster opened this issue Dec 3, 2016 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Dec 3, 2016

Daniel Fernández opened SPR-14975 and commented

Scenario

A Spring Web Reactive application (5.0.0.BUILD-SNAPSHOT) using Spring Boot (2.0.0.BUILD-SNAPSHOT) and running on a Netty server, contains a static resource at its /src/main/resources/static/images folder.

This resource is accessed from a browser or curl, like:

$ curl http://localhost:8080/images/logo.png

Observed Results

An exception is thrown:

2016-12-03 17:55:34.082 ERROR 14751 --- [ctor-http-nio-2] o.s.w.s.h.ExceptionHandlingWebHandler    : Could not complete request

io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: DefaultFileRegion
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:345) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:749) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:741) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:827) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:734) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.handler.codec.http.HttpServerKeepAliveHandler.write(HttpServerKeepAliveHandler.java:87) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:749) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:741) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:827) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:734) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:749) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:812) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:825) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:805) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:842) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1032) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:296) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at reactor.ipc.netty.channel.ChannelOperations.lambda$sendFile$3(ChannelOperations.java:363) ~[reactor-netty-0.6.0.BUILD-SNAPSHOT.jar:na]
	at reactor.core.publisher.MonoUsing.subscribe(MonoUsing.java:83) ~[reactor-core-3.0.3.RELEASE.jar:na]
	at reactor.core.publisher.FluxConcatIterable$ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:152) ~[reactor-core-3.0.3.RELEASE.jar:na]
	at reactor.core.publisher.FluxConcatIterable.subscribe(FluxConcatIterable.java:69) ~[reactor-core-3.0.3.RELEASE.jar:na]
	at reactor.core.publisher.MonoNext.subscribe(MonoNext.java:41) ~[reactor-core-3.0.3.RELEASE.jar:na]
	...
Caused by: java.lang.IllegalStateException: unexpected message type: DefaultFileRegion
	at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:97) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88) ~[netty-all-4.1.6.Final.jar:4.1.6.Final]
	... 109 common frames omitted

Example Application

Please find a very simple example application for reproducing this issue here: https://github.com/danielfernandez/test-spring-boot-reactive-static-netty


Affects: 5.0 M3

Reference URL: https://github.com/danielfernandez/test-spring-boot-reactive-static-netty

Referenced from: commits ba47d06, 953f7d4

0 votes, 5 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 5, 2016

Brian Clozel commented

I've reported this issue against reactor-netty with additional details. This seems to also impact the reactor-netty HTTP client which powers our WebClient.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 5, 2016

Rossen Stoyanchev commented

I've temporarily filtered out Reactor Netty for the two hanging tests so we can get snapshots going again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.