4141 * but also from the classpath, by using the <code>classpath:</code> prefix
4242 * in the location.
4343 *
44- * If default client properties should be set, set the <code>use.default.client.properties</code>
45- * key to <code>true</code>. Custom client properties can be set by using
46- * the <code>client.properties.</code>, e.g. <code>client.properties.app.name</code>.
44+ * Client properties can be set by using
45+ * the <code>client.properties.</code> prefix, e.g. <code>client.properties.app.name</code>.
46+ * Default client properties and custom client properties are merged. To remove
47+ * a default client property, set its key to an empty value.
4748 *
4849 * @since 4.4.0
4950 * @see ConnectionFactory#load(String, String)
@@ -63,7 +64,6 @@ public class ConnectionFactoryConfigurator {
6364 public static final String CONNECTION_TIMEOUT = "connection.timeout" ;
6465 public static final String HANDSHAKE_TIMEOUT = "handshake.timeout" ;
6566 public static final String SHUTDOWN_TIMEOUT = "shutdown.timeout" ;
66- public static final String USE_DEFAULT_CLIENT_PROPERTIES = "use.default.client.properties" ;
6767 public static final String CLIENT_PROPERTIES_PREFIX = "client.properties." ;
6868 public static final String CONNECTION_RECOVERY_ENABLED = "connection.recovery.enabled" ;
6969 public static final String TOPOLOGY_RECOVERY_ENABLED = "topology.recovery.enabled" ;
@@ -169,17 +169,21 @@ public static void load(ConnectionFactory cf, Map<String, String> properties, St
169169 }
170170
171171 Map <String , Object > clientProperties = new HashMap <String , Object >();
172- String useDefaultClientProperties = properties .get (prefix + USE_DEFAULT_CLIENT_PROPERTIES );
173- if (useDefaultClientProperties != null && Boolean .valueOf (useDefaultClientProperties )) {
174- clientProperties .putAll (AMQConnection .defaultClientProperties ());
175- }
172+ Map <String , Object > defaultClientProperties = AMQConnection .defaultClientProperties ();
173+ clientProperties .putAll (defaultClientProperties );
176174
177175 for (Map .Entry <String , String > entry : properties .entrySet ()) {
178176 if (entry .getKey ().startsWith (prefix + CLIENT_PROPERTIES_PREFIX )) {
179- clientProperties .put (
180- entry .getKey ().substring ((prefix + CLIENT_PROPERTIES_PREFIX ).length ()),
181- entry .getValue ()
182- );
177+ String clientPropertyKey = entry .getKey ().substring ((prefix + CLIENT_PROPERTIES_PREFIX ).length ());
178+ if (defaultClientProperties .containsKey (clientPropertyKey ) && (entry .getValue () == null || entry .getValue ().trim ().isEmpty ())) {
179+ // if default property and value is empty, remove this property
180+ clientProperties .remove (clientPropertyKey );
181+ } else {
182+ clientProperties .put (
183+ clientPropertyKey ,
184+ entry .getValue ()
185+ );
186+ }
183187 }
184188 }
185189 cf .setClientProperties (clientProperties );
0 commit comments