StompDecoder StringIndexOutOfBoundsException with Apache ActiveMQ [SPR-12418] #17025
Labels
in: messaging
Issues in messaging modules (jms, messaging)
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Sang-hyun Lee opened SPR-12418 and commented
I'm using the Spring Framework libraries.
1-1. org.springframework.boot:spring-boot-starter-amqp:jar:1.1.8.RELEASE
1-2. org.springframework.boot:spring-boot-starter-websocket:jar:1.1.8.RELEASE
I referneced http://assets.spring.io/wp/WebSocketBlogPost.html
but I'm using the "Apache ActiveMQ 5.10.0" and configured Stomp Broker Relay.
My Application publishing stomp messages to client 5 ~ 30 messages per second.
each message has 300 ~ 700 bytes length of payload.
I meet "StringIndexOutOfBoundsException" irregularly.
and after connection is closed.
stacktrace is below.
java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at java.lang.String.charAt(String.java:658)
at org.springframework.messaging.simp.stomp.StompDecoder.unescape(StompDecoder.java:221)
at org.springframework.messaging.simp.stomp.StompDecoder.readHeaders(StompDecoder.java:197)
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:123)
at org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:99)
at org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:68)
at org.springframework.messaging.simp.stomp.Reactor11StompCodec$DecodingFunction.apply(Reactor11StompCodec.java:96)
at org.springframework.messaging.simp.stomp.Reactor11StompCodec$DecodingFunction.apply(Reactor11StompCodec.java:83)
at reactor.net.AbstractNetChannel.read(AbstractNetChannel.java:214)
at reactor.net.netty.NettyNetChannelInboundHandler.passToConnection(NettyNetChannelInboundHandler.java:105)
at reactor.net.netty.NettyNetChannelInboundHandler.channelRead(NettyNetChannelInboundHandler.java:69)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:332)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:507)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:464)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)
so, I debug the StompDecoder.java (4.0.7.RELEASE source)
and I found out the StompDecoder.unescape() method throws the StringIndexOutOfBoundsException
when message header value end with "". (in my case "message-id" value exactly)
Messages that caused the exception are like below.
CASE #1)
content-type:application/json;charset=UTF-8
message-id:ID
095041.588 ERROR 20569 --- [eactor-tcp-io-4] reactor.core.Reactor : String index out of range: 3
java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at java.lang.String.charAt(String.java:658)
at org.springframework.messaging.simp.stomp.StompDecoder.unescape(StompDecoder.java:221)
at org.springframework.messaging.simp.stomp.StompDecoder.readHeaders(StompDecoder.java:197)
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:123)
... same stack trace...
CASE #2)
content-type:application/json;charset=UTF-8
message-id:ID\cktpdevGW-39005-1415095980735-2\c882\c-1\c1
095056.596 ERROR 20569 --- [eactor-tcp-io-3] reactor.core.Reactor : String index out of range: 47
java.lang.StringIndexOutOfBoundsException: String index out of range: 47
at java.lang.String.charAt(String.java:658)
at org.springframework.messaging.simp.stomp.StompDecoder.unescape(StompDecoder.java:221)
at org.springframework.messaging.simp.stomp.StompDecoder.readHeaders(StompDecoder.java:197)
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:123)
... same stack trace...
CASE #3)
content-type:application/json;charset=UTF-8
message-id:ID\cktpdevGW-39005-1415095980735-2\c882
101513.253 ERROR 20569 --- [eactor-tcp-io-4] reactor.core.Reactor : String index out of range: 40
java.lang.StringIndexOutOfBoundsException: String index out of range: 40
at java.lang.String.charAt(String.java:658)
at org.springframework.messaging.simp.stomp.StompDecoder.unescape(StompDecoder.java:221)
at org.springframework.messaging.simp.stomp.StompDecoder.readHeaders(StompDecoder.java:197)
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:123)
... same stack trace...
every case of messages are ended with "" character.
that messages are looks like incomplete message from the network.
this exception happens on localhost (127.0.0.1 loopback)
Affects: 4.0.7
Issue Links:
Referenced from: commits 1803348, b331d65
Backported to: 4.0.8
The text was updated successfully, but these errors were encountered: