From 457e96b039a611e87bd8a4e7eb605525e0a815f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Andr=C3=A9=20Pearce?= Date: Fri, 2 Feb 2018 09:52:38 +0000 Subject: [PATCH] ARTEMIS-1655 TransportConfiguration - only encode non-null values Check for null, to avoid encoding issue, this is seen on failover. --- .../api/core/TransportConfiguration.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java index 7fcfcd5e1b5..b8e2091a85e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java @@ -297,24 +297,26 @@ public static String toStringParameters(Map params, Map map) { for (Map.Entry entry : map.entrySet()) { - buffer.writeString(entry.getKey()); - - Object val = entry.getValue(); - - if (val instanceof Boolean) { - buffer.writeByte(TransportConfiguration.TYPE_BOOLEAN); - buffer.writeBoolean((Boolean) val); - } else if (val instanceof Integer) { - buffer.writeByte(TransportConfiguration.TYPE_INT); - buffer.writeInt((Integer) val); - } else if (val instanceof Long) { - buffer.writeByte(TransportConfiguration.TYPE_LONG); - buffer.writeLong((Long) val); - } else if (val instanceof String) { - buffer.writeByte(TransportConfiguration.TYPE_STRING); - buffer.writeString((String) val); - } else { - throw ActiveMQClientMessageBundle.BUNDLE.invalidEncodeType(val); + if (entry.getValue() != null) { + buffer.writeString(entry.getKey()); + + Object val = entry.getValue(); + + if (val instanceof Boolean) { + buffer.writeByte(TransportConfiguration.TYPE_BOOLEAN); + buffer.writeBoolean((Boolean) val); + } else if (val instanceof Integer) { + buffer.writeByte(TransportConfiguration.TYPE_INT); + buffer.writeInt((Integer) val); + } else if (val instanceof Long) { + buffer.writeByte(TransportConfiguration.TYPE_LONG); + buffer.writeLong((Long) val); + } else if (val instanceof String) { + buffer.writeByte(TransportConfiguration.TYPE_STRING); + buffer.writeString((String) val); + } else { + throw ActiveMQClientMessageBundle.BUNDLE.invalidEncodeType(val); + } } } }