This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 14f8e8d ARTEMIS-3363 Fix TransportConfiguration extraParams equals
14f8e8d is described below
commit 14f8e8d5abeb8417f177763edab7982f312a5e0f
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Thu Oct 21 14:46:51 2021 +0200
ARTEMIS-3363 Fix TransportConfiguration extraParams equals
---
.../artemis/api/core/TransportConfiguration.java | 5 ++---
.../artemis/api/core/TransportConfigurationTest.java | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 3 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 609b9c1..15a3b52 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
@@ -222,9 +222,8 @@ public class TransportConfiguration implements Serializable
{
return false;
}
- // Empty and null extraProps maps are equivalent so the condition to
check if two extraProps maps are equal is:
- // (extraProps == that.extraProps) || (extraProps != null &&
((extraProps.isEmpty() && that.extraProps == null) ||
extraProps.equals(that.extraProps)))
- if ((extraProps != that.extraProps) && (extraProps == null ||
((!extraProps.isEmpty() || that.extraProps != null) &&
!extraProps.equals(that.extraProps)))) {
+ // Empty and null extraProps maps are equivalent so the condition to
check if two extraProps maps are not equal is:
+ if ((extraProps != that.extraProps) && (extraProps != null ||
!that.extraProps.isEmpty()) && (that.extraProps != null ||
!extraProps.isEmpty()) && (extraProps == null || that.extraProps == null ||
!extraProps.equals(that.extraProps))) {
return false;
}
diff --git
a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java
index 0f02e90..bb39418 100644
---
a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java
+++
b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/TransportConfigurationTest.java
@@ -68,6 +68,24 @@ public class TransportConfigurationTest {
}
@Test
+ public void testExtraParamsEquals() {
+ final String name = "";
+ final String className = this.getClass().getName();
+ final Map<String, Object> params = Collections.emptyMap();
+ final Map<String, Object> extraParams = Collections.singletonMap("key",
"foo");
+
+ Assert.assertEquals(new TransportConfiguration(className, params, name,
null), new TransportConfiguration(className, params, name, null));
+ Assert.assertEquals(new TransportConfiguration(className, params, name,
null), new TransportConfiguration(className, params, name,
Collections.emptyMap()));
+ Assert.assertEquals(new TransportConfiguration(className, params, name,
Collections.emptyMap()), new TransportConfiguration(className, params, name,
null));
+ Assert.assertEquals(new TransportConfiguration(className, params, name,
extraParams), new TransportConfiguration(className, params, name, extraParams));
+ Assert.assertEquals(new TransportConfiguration(className, params, name,
extraParams), new TransportConfiguration(className, params, name, new
HashMap<>(extraParams)));
+
+ Assert.assertNotEquals(new TransportConfiguration(className, params,
name, null), new TransportConfiguration(className, params, name, extraParams));
+ Assert.assertNotEquals(new TransportConfiguration(className, params,
name, Collections.emptyMap()), new TransportConfiguration(className, params,
name, extraParams));
+ Assert.assertNotEquals(new TransportConfiguration(className, params,
name, extraParams), new TransportConfiguration(className, params, name,
Collections.singletonMap("key", "too")));
+ }
+
+ @Test
public void testToStringObfuscatesPasswords() {
HashMap<String, Object> params = new HashMap<>();
params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME,
"secret_password");