ARTEMIS-4106 do not set prop w/empty key when converting to OpenWire
This commit is contained in:
parent
44cec5976c
commit
ef04cec95d
|
@ -27,6 +27,7 @@ import java.io.DataOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -75,12 +76,16 @@ import org.apache.activemq.util.ByteSequenceData;
|
|||
import org.apache.activemq.util.MarshallingSupport;
|
||||
import org.apache.activemq.wireformat.WireFormat;
|
||||
import org.fusesource.hawtbuf.UTF8Buffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.activemq.artemis.api.core.Message.HDR_INGRESS_TIMESTAMP;
|
||||
import static org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE;
|
||||
|
||||
public final class OpenWireMessageConverter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public OpenWireMessageConverter() {
|
||||
|
||||
}
|
||||
|
@ -927,6 +932,10 @@ public final class OpenWireMessageConverter {
|
|||
final Set<SimpleString> props) throws IOException {
|
||||
for (SimpleString s : props) {
|
||||
final String keyStr = s.toString();
|
||||
if (keyStr.length() == 0) {
|
||||
logger.debug("ignoring property with empty key name");
|
||||
continue;
|
||||
}
|
||||
if (!coreMessage.containsProperty(ManagementHelper.HDR_NOTIFICATION_TYPE) && (keyStr.startsWith("_AMQ") || keyStr.startsWith("__HDR_"))) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -249,6 +249,9 @@ public class OpenWireMessageConverterTest {
|
|||
coreMessage.putStringProperty(hdrCommandId, "foo");
|
||||
coreMessage.putStringProperty(hdrDroppable, "true");
|
||||
|
||||
// this has triggered a java.lang.IllegalArgumentException during conversion in the past
|
||||
coreMessage.putStringProperty("", "bar");
|
||||
|
||||
MessageReference messageReference = new MessageReferenceImpl(coreMessage, Mockito.mock(Queue.class));
|
||||
AMQConsumer amqConsumer = Mockito.mock(AMQConsumer.class);
|
||||
Mockito.when(amqConsumer.getOpenwireDestination()).thenReturn(destination);
|
||||
|
@ -259,5 +262,6 @@ public class OpenWireMessageConverterTest {
|
|||
assertNull(messageDispatch.getMessage().getProperty(hdrBrokerInTime));
|
||||
assertNull(messageDispatch.getMessage().getProperty(hdrCommandId));
|
||||
assertNull(messageDispatch.getMessage().getProperty(hdrDroppable));
|
||||
assertNull(messageDispatch.getMessage().getProperty(""));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue