1 Reply Latest reply on Feb 28, 2009 5:12 PM by Andy Taylor

    ExpandableBuffers and HTTP

    Clebert Suconic Master

      Andy: As we talked today:

      If you change NettyConnection:

      public MessagingBuffer createBuffer(final int size)
       {
      + return new ChannelBufferWrapper(org.jboss.netty.buffer.ChannelBuffers.buffer(size));
      - return new ChannelBufferWrapper(org.jboss.netty.buffer.ChannelBuffers.dynamicBuffer(size));
       }
      
      


      org.jboss.messaging.tests.integration.http.NettyHttpTest would have a bunch of failures:


      Exception in thread "pool-3-thread-23" java.lang.ArrayIndexOutOfBoundsException
       at org.jboss.netty.buffer.HeapChannelBuffer.setBytes(HeapChannelBuffer.java:130)
       at org.jboss.netty.buffer.HeapChannelBuffer.setBytes(HeapChannelBuffer.java:123)
       at org.jboss.netty.buffer.AbstractChannelBuffer.writeBytes(AbstractChannelBuffer.java:411)
       at org.jboss.netty.buffer.AbstractChannelBuffer.writeBytes(AbstractChannelBuffer.java:406)
       at org.jboss.netty.buffer.AbstractChannelBuffer.writeBytes(AbstractChannelBuffer.java:399)
       at org.jboss.messaging.integration.transports.netty.HttpAcceptorHandler$ResponseRunner.piggyBackResponses(HttpAcceptorHandler.java:202)
       at org.jboss.messaging.integration.transports.netty.HttpAcceptorHandler$ResponseRunner.run(HttpAcceptorHandler.java:181)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
       at java.lang.Thread.run(Thread.java:619)
      


      You probably need to call netty.Buffers.dynamic directly instead of using NettyConnection.createBuffer, or maybe we should create another method on Connection for createDynamicBuffer.

      (I don't know if it would be possible to know the size of the buffer you need, since this will probably using HTTPEncoding)