I have the following simple code in my netty project, it expects to read an integer from the upstream. No encoder is in the pipeline.
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
ChannelBuffer m = (ChannelBuffer) e.getMessage();
m.readInt()
}
When the data comes in from the network the method is fired correctly (good sign) but when attempting to read, it gives the following error:
java.lang.IndexOutOfBoundsException
at org.jboss.netty.buffer.AbstractChannelBuffer.checkReadableBytes(AbstractChannelBuffer.java:657)
at org.jboss.netty.buffer.AbstractChannelBuffer.readInt(AbstractChannelBuffer.java:272)
at PushServer.Netty.PushClientHandler.messageReceived(PushClientHandler.java:33)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
Any ideas?