Repository: activemq Updated Branches: refs/heads/trunk a3701fcb9 -> 5e14eecce
Fix for AMQ-5099, removed dead code Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/5e14eecc Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/5e14eecc Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/5e14eecc Branch: refs/heads/trunk Commit: 5e14eecce6420390e8bfe1a12870bbdd20a2df03 Parents: a3701fc Author: Kevin Earls <[email protected]> Authored: Wed Mar 19 19:00:34 2014 +0100 Committer: Kevin Earls <[email protected]> Committed: Wed Mar 19 19:00:34 2014 +0100 ---------------------------------------------------------------------- .../activemq/openwire/OpenWireFormat.java | 97 ++++++++------------ 1 file changed, 40 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/5e14eecc/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java ---------------------------------------------------------------------- diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java index 175790a..e605a4e 100755 --- a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java +++ b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java @@ -119,74 +119,57 @@ public final class OpenWireFormat implements WireFormat { runMarshallCacheEvictionSweep(); } -// MarshallAware ma = null; -// // If not using value caching, then the marshaled form is always the -// // same -// if (!cacheEnabled && ((DataStructure)command).isMarshallAware()) { -// ma = (MarshallAware)command; -// } - ByteSequence sequence = null; - // if( ma!=null ) { - // sequence = ma.getCachedMarshalledForm(this); - // } + int size = 1; + if (command != null) { - if (sequence == null) { + DataStructure c = (DataStructure)command; + byte type = c.getDataStructureType(); + DataStreamMarshaller dsm = (DataStreamMarshaller)dataMarshallers[type & 0xFF]; + if (dsm == null) { + throw new IOException("Unknown data type: " + type); + } + if (tightEncodingEnabled) { - int size = 1; - if (command != null) { + BooleanStream bs = new BooleanStream(); + size += dsm.tightMarshal1(this, c, bs); + size += bs.marshalledSize(); - DataStructure c = (DataStructure)command; - byte type = c.getDataStructureType(); - DataStreamMarshaller dsm = (DataStreamMarshaller)dataMarshallers[type & 0xFF]; - if (dsm == null) { - throw new IOException("Unknown data type: " + type); - } - if (tightEncodingEnabled) { - - BooleanStream bs = new BooleanStream(); - size += dsm.tightMarshal1(this, c, bs); - size += bs.marshalledSize(); - - bytesOut.restart(size); - if (!sizePrefixDisabled) { - bytesOut.writeInt(size); - } - bytesOut.writeByte(type); - bs.marshal(bytesOut); - dsm.tightMarshal2(this, c, bytesOut, bs); - sequence = bytesOut.toByteSequence(); - - } else { - bytesOut.restart(); - if (!sizePrefixDisabled) { - bytesOut.writeInt(0); // we don't know the final size - // yet but write this here for - // now. - } - bytesOut.writeByte(type); - dsm.looseMarshal(this, c, bytesOut); - sequence = bytesOut.toByteSequence(); - - if (!sizePrefixDisabled) { - size = sequence.getLength() - 4; - int pos = sequence.offset; - ByteSequenceData.writeIntBig(sequence, size); - sequence.offset = pos; - } + bytesOut.restart(size); + if (!sizePrefixDisabled) { + bytesOut.writeInt(size); } + bytesOut.writeByte(type); + bs.marshal(bytesOut); + dsm.tightMarshal2(this, c, bytesOut, bs); + sequence = bytesOut.toByteSequence(); } else { - bytesOut.restart(5); - bytesOut.writeInt(size); - bytesOut.writeByte(NULL_TYPE); + bytesOut.restart(); + if (!sizePrefixDisabled) { + bytesOut.writeInt(0); // we don't know the final size + // yet but write this here for + // now. + } + bytesOut.writeByte(type); + dsm.looseMarshal(this, c, bytesOut); sequence = bytesOut.toByteSequence(); + + if (!sizePrefixDisabled) { + size = sequence.getLength() - 4; + int pos = sequence.offset; + ByteSequenceData.writeIntBig(sequence, size); + sequence.offset = pos; + } } - // if( ma!=null ) { - // ma.setCachedMarshalledForm(this, sequence); - // } + } else { + bytesOut.restart(5); + bytesOut.writeInt(size); + bytesOut.writeByte(NULL_TYPE); + sequence = bytesOut.toByteSequence(); } + return sequence; }
