[ 
https://issues.apache.org/jira/browse/QPID-6968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15081696#comment-15081696
 ] 

Rob Godfrey commented on QPID-6968:
-----------------------------------

The change in the patch looks good.

I don't think removing the _offset altogether would be safe unless we could 
guarantee that asDataInput() was only called on buffers where the initial 
position is 0.

Ideally for 6.1 we might look at getting rid of BufferDataInput and instead 
using the QpidByteBuffer directly (as we have done on the output side), but 
that would clear fall under a separate JIRA :-)



> [Java Broker] Decoding of pipelined AMQP 0-9.x frames can fails when multiple 
> frames are received as part of the same byte buffer
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: QPID-6968
>                 URL: https://issues.apache.org/jira/browse/QPID-6968
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Broker
>    Affects Versions: qpid-java-6.0
>            Reporter: Alex Rudyy
>            Priority: Blocker
>             Fix For: qpid-java-6.1
>
>         Attachments: 
> 0001-QPID-6968-Fix-setting-of-position-in-org.apache.qpid.patch
>
>
> Decoding of pipelined  protocol initiation and frames for connection opening 
> (ConnectionStartOk), etc might fails with AMQFrameDecodingException when 
> protocol initiation and following frames (connection start ok, connection 
> tune ok, etc) are received as part of the same byte buffer.
> The following exception is reported on frame decoding:
> {noformat}
> 016-01-04 18:31:37,152         ERROR [IO-/127.0.0.1:33680] 
> o.a.q.s.p.v.AMQPConnection_0_8 Unexpected exception
> org.apache.qpid.framing.AMQFrameDecodingException: Unsupported frame type: 65
>         at org.apache.qpid.codec.AMQDecoder.processFrame(AMQDecoder.java:215) 
> ~[qpid-common-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.protocol.v0_8.BrokerDecoder.doProcessFrame(BrokerDecoder.java:118)
>  ~[qpid-broker-plugins-amqp-0-8-protocol-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.protocol.v0_8.BrokerDecoder.processFrame(BrokerDecoder.java:65)
>  ~[qpid-broker-plugins-amqp-0-8-protocol-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at org.apache.qpid.codec.AMQDecoder.processInput(AMQDecoder.java:185) 
> ~[qpid-common-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at org.apache.qpid.codec.AMQDecoder.decode(AMQDecoder.java:125) 
> ~[qpid-common-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.codec.ServerDecoder.decodeBuffer(ServerDecoder.java:43) 
> ~[qpid-common-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.protocol.v0_8.AMQPConnection_0_8$1.run(AMQPConnection_0_8.java:266)
>  [qpid-broker-plugins-amqp-0-8-protocol-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.protocol.v0_8.AMQPConnection_0_8$1.run(AMQPConnection_0_8.java:258)
>  [qpid-broker-plugins-amqp-0-8-protocol-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at java.security.AccessController.doPrivileged(Native Method) 
> [na:1.7.0_80]
>         at 
> org.apache.qpid.server.protocol.v0_8.AMQPConnection_0_8.received(AMQPConnection_0_8.java:257)
>  [qpid-broker-plugins-amqp-0-8-protocol-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.MultiVersionProtocolEngine$SelfDelegateProtocolEngine.received(MultiVersionProtocolEngine.java:526)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.MultiVersionProtocolEngine.received(MultiVersionProtocolEngine.java:142)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.NonBlockingConnection.processAmqpData(NonBlockingConnection.java:547)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.NonBlockingConnectionPlainDelegate.processData(NonBlockingConnectionPlainDelegate.java:58)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.NonBlockingConnection.doRead(NonBlockingConnection.java:446)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.NonBlockingConnection.doWork(NonBlockingConnection.java:253)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.NetworkConnectionScheduler.processConnection(NetworkConnectionScheduler.java:108)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.SelectorThread$ConnectionProcessor.processConnection(SelectorThread.java:499)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.performSelect(SelectorThread.java:337)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(SelectorThread.java:86)
>  [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> org.apache.qpid.server.transport.SelectorThread.run(SelectorThread.java:457) 
> [qpid-broker-core-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  [na:1.7.0_80]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  [na:1.7.0_80]
>         at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
> {noformat}
> After receiving protocol initiation QpidByteBuffer.BufferDataInput#_offset is 
> set to 8. On decoding ConnectionStartOk, invocation of 
> org.apache.qpid.codec.AMQDecoder#decodable sets the QpidByteBuffer position 
> to 0 after parsing frame body size and resting of 
> QpidByteBuffer.BufferDataInput.
> QpidByteBuffer.BufferDataInput#reset sets the position of byte buffer without 
> accounting for QpidByteBuffer.BufferDataInput#_offset:
> {code}
>         public void reset()
>         {
>             _buffer.position(_mark);
>         }
> {code}
> IMHO, it should be
> {code}
>         public void reset()
>         {
>             position(_mark);
>         }
> {code}
> It looks like field QpidByteBuffer.BufferDataInput#_offset is redundant. At 
> least, I do not see any obvious reasons to have this field. Thus, another way 
> to fix the problem is deletion of  QpidByteBuffer.BufferDataInput#_offset  
> and invocation of methods of QpidByteBuffer to set/get the position from 
> org.apache.qpid.bytebuffer.QpidByteBuffer.BufferDataInput#position()
> org.apache.qpid.bytebuffer.QpidByteBuffer.BufferDataInput#position(int)
> Additionally, methods QpidByteBuffer.BufferDataInput#position... could be 
> in-lined.
> We might want to port the fix into 6.0.x branch



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to