Couchbase DCP Client 0.10.0 fails with java.lang.IndexOutOfBoundsException for DcpMutationMessage

dcp
java

#1

My environment:

  • DCP Client version 0.10.0
  • Core IO version 1.4.4
  • Java SDK version 2.4.4
  • RxJava version 1.2.7

While calling DcpMutationMessage.contentBytes(byteBuf), I am getting following exception

2017-06-26 16:37:49.492 [Thread: nioEventLoopGroup-5-2] WARN com.couchbase.client.deps.io.netty.channel.DefaultChannelPipeline# - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.IndexOutOfBoundsException: index: 0, length: 549 (expected: range(0, 477))
	at com.couchbase.client.deps.io.netty.buffer.AbstractByteBuf.checkIndex0(AbstractByteBuf.java:1125) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.buffer.SlicedByteBuf.getBytes(SlicedByteBuf.java:199) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.buffer.AbstractByteBuf.getBytes(AbstractByteBuf.java:440) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.dcp.message.DcpMutationMessage.contentBytes(DcpMutationMessage.java:50) ~[dcp-client-0.10.0.jar:?]
	at com.demo.dcpclient.util.function.Functions.lambda$7(Functions.java:149) ~[bin/:?]
	at com.demo.dcpclient.listener.DCPEventListenerRunnable.lambda$1(DCPEventListenerRunnable.java:185) ~[bin/:?]
	at com.couchbase.client.dcp.Client$3.onEvent(Client.java:295) ~[dcp-client-0.10.0.jar:?]
	at com.couchbase.client.dcp.transport.netty.DcpMessageHandler.channelRead(DcpMessageHandler.java:87) ~[dcp-client-0.10.0.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:625) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:560) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:477) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:439) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131) ~[core-io-1.4.4.jar:?]
	at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) ~[core-io-1.4.4.jar:?]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

The code that is throwing this exception is MessageUtil.getContent(byteBuf) (line # 203 which is buffer.slice().

This is causing a huge roadblock for our current development. Appreciate if anybody can help us.

P.S.: I do not have a JIRA account; hence, creating a topic here.


#2

@avsej can you help us here?


#3

The 0.11 picks up a new core, and to make sure we track against this I’ve filed JDCP-57. That may be fixed by that new core update, which you can build yourself to try to help test.

The commit with the new core update is here: https://github.com/couchbaselabs/java-dcp-client/commit/9b373d0fea522ae88b844e1773139fb83aca2a5f

Track that issue though. Thanks!


#4

@ingenthr i tried using the code from the GitHub link you provided. It fixes one of the bugs that I was getting earlier (Couchbase DCP Client 0.10.0 fails with java.lang.NoSuchMethodError), but this Index OOB exception is still there.

The exception is thrown from DCP client MessageUtil.getContent(byteBuf) line # 203 which is buffer.slice().

I am keeping an eye on the JIRA; but do you have any timeline in your mind for the fix?

Thanks,
Niranjan


#5

Thanks for the update and testing. Good to know. I don’t have a timeline exactly, since I don’t think we know root cause quite yet. @avsej and I talked earlier and he was going to have a look today/tomorrow (he’s in Europe). He’ll probably update this thread or the issue.


#6

Sounds good. Thank you for the information.


#7

Hi @niranjan.nanda, I’ve fixed issue on master. contentBytes is basically handy shortcut on content method, so you can workaround it using the following code:

ByteBuf content = DcpMutationMessage.content(event);
byte[] bytes = new byte[content.readableBytes()];
content.getBytes(content.readerIndex(), bytes);

#8

Hi @ingenthr, @avsej, I took the code today from master and could see this bug fixed. I am able to consume message content from events.

Current master has fixed two issues faced by us (Core-IO and this), so, we would like to see if this can be released asap. Any timeline in mind?

Thanks,
Niranjan


#9

It is currently passed to our QE team, and once they will check that there are no new regressions – I’ll make release.


#10

@avsej Any update on this?


#11

HI @niranjan.nanda, sorry for delay, I’ve just published 0.11.0: https://github.com/couchbaselabs/java-dcp-client/releases/tag/0.11.0

It is already accessible on maven central.
http://search.maven.org/#artifactdetails|com.couchbase.client|dcp-client|0.11.0|jar