AMQ-7191 - Prevent extra creation of openwire verifier objects per new

connection when using the auto transport
This commit is contained in:
Christopher L. Shannon (cshannon) 2019-04-30 08:41:08 -04:00
parent aff9413cdb
commit bf3a9f44f6
2 changed files with 7 additions and 12 deletions

View File

@ -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);
}

View File

@ -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) {