Repository: qpid-proton Updated Branches: refs/heads/master 611e26e7f -> 77fa91e9c
PROTON-966, PROTON-967: add EmptyFrame body and pass to frame handler like any other. Utilise this to make empty frame logging/tracing actually say Empty Frame instead of just null. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/77fa91e9 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/77fa91e9 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/77fa91e9 Branch: refs/heads/master Commit: 77fa91e9cdbc640ffd67d331d3553d3e5060865e Parents: 611e26e Author: Robert Gemmell <rob...@apache.org> Authored: Thu Jul 30 12:06:31 2015 +0100 Committer: Robert Gemmell <rob...@apache.org> Committed: Thu Jul 30 12:15:21 2015 +0100 ---------------------------------------------------------------------- .../qpid/proton/amqp/transport/EmptyFrame.java | 38 ++++++++++++++ .../qpid/proton/engine/impl/FrameParser.java | 53 ++++++++++---------- .../qpid/proton/engine/impl/FrameWriter.java | 14 +++++- 3 files changed, 77 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/77fa91e9/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java new file mode 100644 index 0000000..b085e84 --- /dev/null +++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/EmptyFrame.java @@ -0,0 +1,38 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.qpid.proton.amqp.transport; + +import org.apache.qpid.proton.amqp.Binary; + +public final class EmptyFrame implements FrameBody +{ + @Override + public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context) + { + // NO-OP + } + + @Override + public String toString() + { + return "Empty Frame"; + } +} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/77fa91e9/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java index 4c4f137..e30bdc1 100644 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java +++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser.java @@ -29,6 +29,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.apache.qpid.proton.amqp.Binary; +import org.apache.qpid.proton.amqp.transport.EmptyFrame; import org.apache.qpid.proton.amqp.transport.FrameBody; import org.apache.qpid.proton.codec.ByteBufferDecoder; import org.apache.qpid.proton.codec.DecodeException; @@ -370,14 +371,15 @@ class FrameParser implements TransportInput { _framesInput += 1; + Binary payload = null; + Object val = null; + if (frameBodySize > 0) { _decoder.setByteBuffer(in); - Object val = _decoder.readObject(); + val = _decoder.readObject(); _decoder.setByteBuffer(null); - Binary payload; - if(in.hasRemaining()) { byte[] payloadBytes = new byte[in.remaining()]; @@ -388,41 +390,38 @@ class FrameParser implements TransportInput { payload = null; } + } + else + { + val = new EmptyFrame(); + } - if(val instanceof FrameBody) + if(val instanceof FrameBody) + { + FrameBody frameBody = (FrameBody) val; + if(TRACE_LOGGER.isLoggable(Level.FINE)) { - FrameBody frameBody = (FrameBody) val; - if(TRACE_LOGGER.isLoggable(Level.FINE)) - { - TRACE_LOGGER.log(Level.FINE, "IN: CH["+channel+"] : " + frameBody + (payload == null ? "" : "[" + payload + "]")); - } - TransportFrame frame = new TransportFrame(channel, frameBody, payload); - - if(_frameHandler.isHandlingFrames()) - { - _tail_closed = _frameHandler.handleFrame(frame); - } - else - { - transportAccepting = false; - _heldFrame = frame; - } + TRACE_LOGGER.log(Level.FINE, "IN: CH["+channel+"] : " + frameBody + (payload == null ? "" : "[" + payload + "]")); + } + TransportFrame frame = new TransportFrame(channel, frameBody, payload); + if(_frameHandler.isHandlingFrames()) + { + _tail_closed = _frameHandler.handleFrame(frame); } else { - throw new TransportException("Frameparser encountered a " - + (val == null? "null" : val.getClass()) - + " which is not a " + FrameBody.class); + transportAccepting = false; + _heldFrame = frame; } } else { - if(TRACE_LOGGER.isLoggable(Level.FINEST)) - { - TRACE_LOGGER.finest("Ignored empty frame"); - } + throw new TransportException("Frameparser encountered a " + + (val == null? "null" : val.getClass()) + + " which is not a " + FrameBody.class); } + reset(); in = oldIn; oldIn = null; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/77fa91e9/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java index aaff3e8..fb1b06a 100644 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java +++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java @@ -21,6 +21,7 @@ package org.apache.qpid.proton.engine.impl; import org.apache.qpid.proton.amqp.Binary; +import org.apache.qpid.proton.amqp.transport.EmptyFrame; import org.apache.qpid.proton.amqp.transport.FrameBody; import org.apache.qpid.proton.codec.EncoderImpl; import org.apache.qpid.proton.codec.WritableBuffer; @@ -166,7 +167,18 @@ class FrameWriter } Binary payloadBin = Binary.create(originalPayload); - TransportFrame frame = new TransportFrame(channel, (FrameBody) frameBody, payloadBin); + FrameBody body = null; + if (frameBody == null) + { + body = new EmptyFrame(); + } + else + { + body = (FrameBody) frameBody; + } + + TransportFrame frame = new TransportFrame(channel, body, payloadBin); + _transport.log(TransportImpl.OUTGOING, frame); if(tracer != null) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org