java.nio.ReadOnlyBufferException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When passing ReadOnly buffer (ByteBuffer.wrap(arr).asReadOnlyBuffer()) to Blob type field, the driver seems to fail to construct message with following found in log : {code} com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing at com.datastax.driver.core.Connection$10.operationComplete(Connection.java:564) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Connection$10.operationComplete(Connection.java:548) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:621) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:138) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at com.datastax.driver.core.Connection$Flusher.run(Connection.java:878) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40] Caused by: io.netty.handler.codec.EncoderException: java.nio.ReadOnlyBufferException at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[netty-codec-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:643) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:700) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:636) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:284) ~[netty-handler-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:643) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:700) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:636) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:622) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:939) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannel.write(AbstractChannel.java:234) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] ... 5 common frames omitted Caused by: java.nio.ReadOnlyBufferException: null at java.nio.ByteBuffer.array(ByteBuffer.java:996) ~[na:1.8.0_40] at io.netty.buffer.UnsafeByteBufUtil.setBytes(UnsafeByteBufUtil.java:368) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:205) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:877) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at com.datastax.driver.core.CBUtil.writeValue(CBUtil.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.CBUtil.writeValueList(CBUtil.java:344) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$QueryProtocolOptions.encode(Requests.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$Execute$1.encode(Requests.java:169) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$Execute$1.encode(Requests.java:165) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Message$ProtocolEncoder.encode(Message.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Message$ProtocolEncoder.encode(Message.java:280) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[netty-codec-4.0.33.Final.jar:4.0.33.Final] ... 15 common frames omitted {code} That in fact causes following exception to be propagated {code} All host(s) tried for query failed (tried: /127.0.0.1:12000 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing)) com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:12000 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing)) at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:211) at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:43) at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:277) at com.datastax.driver.core.RequestHandler$SpeculativeExecution$1.run(RequestHandler.java:400) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} making the connection with server defunct. Expected behaviour. 1) If the buffer must not be read-only, then this shall be asserted immediatelly when the row of blob field is constructed 2) Only that particular request shall fail, reporting the exception back, connection shall be availble for further request 3) Even when connection will fail for this reason, driver shall be able to allocate new connection w/o dormant time pretending that server have failed.
    via by Pavel Chlupacek,
  • When passing ReadOnly buffer (ByteBuffer.wrap(arr).asReadOnlyBuffer()) to Blob type field, the driver seems to fail to construct message with following found in log : {code} com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing at com.datastax.driver.core.Connection$10.operationComplete(Connection.java:564) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Connection$10.operationComplete(Connection.java:548) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:621) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:138) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at com.datastax.driver.core.Connection$Flusher.run(Connection.java:878) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) ~[netty-common-4.0.33.Final.jar:4.0.33.Final] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40] Caused by: io.netty.handler.codec.EncoderException: java.nio.ReadOnlyBufferException at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[netty-codec-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:643) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:700) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:636) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:284) ~[netty-handler-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:643) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:700) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:636) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:622) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.DefaultChannelPipeline.write(DefaultChannelPipeline.java:939) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] at io.netty.channel.AbstractChannel.write(AbstractChannel.java:234) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final] ... 5 common frames omitted Caused by: java.nio.ReadOnlyBufferException: null at java.nio.ByteBuffer.array(ByteBuffer.java:996) ~[na:1.8.0_40] at io.netty.buffer.UnsafeByteBufUtil.setBytes(UnsafeByteBufUtil.java:368) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:205) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:877) ~[netty-buffer-4.0.33.Final.jar:4.0.33.Final] at com.datastax.driver.core.CBUtil.writeValue(CBUtil.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.CBUtil.writeValueList(CBUtil.java:344) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$QueryProtocolOptions.encode(Requests.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$Execute$1.encode(Requests.java:169) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Requests$Execute$1.encode(Requests.java:165) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Message$ProtocolEncoder.encode(Message.java:319) ~[cassandra-driver-core-3.0.1.jar:na] at com.datastax.driver.core.Message$ProtocolEncoder.encode(Message.java:280) ~[cassandra-driver-core-3.0.1.jar:na] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[netty-codec-4.0.33.Final.jar:4.0.33.Final] ... 15 common frames omitted {code} That in fact causes following exception to be propagated {code} All host(s) tried for query failed (tried: /127.0.0.1:12000 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing)) com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:12000 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1] Error writing)) at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:211) at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:43) at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:277) at com.datastax.driver.core.RequestHandler$SpeculativeExecution$1.run(RequestHandler.java:400) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} making the connection with server defunct. Expected behaviour. 1) If the buffer must not be read-only, then this shall be asserted immediatelly when the row of blob field is constructed 2) Only that particular request shall fail, reporting the exception back, connection shall be availble for further request 3) Even when connection will fail for this reason, driver shall be able to allocate new connection w/o dormant time pretending that server have failed.
    via by Pavel Chlupacek,
    • java.nio.ReadOnlyBufferException at java.nio.ByteBuffer.array(ByteBuffer.java:723) at sun.nio.ch.IOUtil.write(IOUtil.java:168) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:334) at com.tc.net.core.TCConnectionJDK14.doWriteInternal(TCConnectionJDK14.java:385) at com.tc.net.core.TCConnectionJDK14.doWrite(TCConnectionJDK14.java:228) at com.tc.net.core.CoreNIOServices$CommThread.selectLoop(CoreNIOServices.java:622) at com.tc.net.core.CoreNIOServices$CommThread.run(CoreNIOServices.java:286)
    No Bugmate found.