diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/auto/AutoTcpTransportServer.java b/activemq-broker/src/main/java/org/apache/activemq/transport/auto/AutoTcpTransportServer.java index 309e368508..7ec4de8f38 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/transport/auto/AutoTcpTransportServer.java +++ b/activemq-broker/src/main/java/org/apache/activemq/transport/auto/AutoTcpTransportServer.java @@ -99,9 +99,6 @@ public class AutoTcpTransportServer extends TcpTransportServer { } IntrospectionSupport.setProperties(wff, wfOptions); } - if (wff instanceof OpenWireFormatFactory) { - protocolVerifiers.put(AutoTransportUtils.OPENWIRE, new OpenWireProtocolVerifier((OpenWireFormatFactory) wff)); - } return wff; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create wire format factory for: " + scheme + ", reason: " + e, e); @@ -238,9 +235,9 @@ public class AutoTcpTransportServer extends TcpTransportServer { if (isAllProtocols() || enabledProtocols.contains(AutoTransportUtils.OPENWIRE)) { OpenWireProtocolVerifier owpv; if (wireFormatFactory instanceof OpenWireFormatFactory) { - owpv = new OpenWireProtocolVerifier((OpenWireFormatFactory) wireFormatFactory); + owpv = new OpenWireProtocolVerifier(((OpenWireFormatFactory) wireFormatFactory).isSizePrefixDisabled()); } else { - owpv = new OpenWireProtocolVerifier(new OpenWireFormatFactory()); + owpv = new OpenWireProtocolVerifier(new OpenWireFormatFactory().isSizePrefixDisabled()); } protocolVerifiers.put(AutoTransportUtils.OPENWIRE, owpv); } diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/protocol/OpenWireProtocolVerifier.java b/activemq-broker/src/main/java/org/apache/activemq/transport/protocol/OpenWireProtocolVerifier.java index 71277c25c1..fe4774580b 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/transport/protocol/OpenWireProtocolVerifier.java +++ b/activemq-broker/src/main/java/org/apache/activemq/transport/protocol/OpenWireProtocolVerifier.java @@ -17,19 +17,17 @@ package org.apache.activemq.transport.protocol; import org.apache.activemq.command.WireFormatInfo; -import org.apache.activemq.openwire.OpenWireFormat; -import org.apache.activemq.openwire.OpenWireFormatFactory; /** * * */ -public class OpenWireProtocolVerifier implements ProtocolVerifier { +public class OpenWireProtocolVerifier implements ProtocolVerifier { - protected final OpenWireFormatFactory wireFormatFactory; + protected final boolean sizePrefixDisabled; - public OpenWireProtocolVerifier(OpenWireFormatFactory wireFormatFactory) { - this.wireFormatFactory = wireFormatFactory; + public OpenWireProtocolVerifier(final boolean sizePrefixDisabled) { + this.sizePrefixDisabled = sizePrefixDisabled; } /* (non-Javadoc) @@ -42,7 +40,7 @@ public class OpenWireProtocolVerifier implements ProtocolVerifier { + value.length); } - int start = !((OpenWireFormat)wireFormatFactory.createWireFormat()).isSizePrefixDisabled() ? 4 : 0; + int start = !sizePrefixDisabled ? 4 : 0; int j = 0; // type if (value[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) {