activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1299 support commas in RA connection parameter values
Date Fri, 28 Jul 2017 22:01:28 GMT
ARTEMIS-1299 support commas in RA connection parameter values


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8c8ab0ad
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8c8ab0ad
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8c8ab0ad

Branch: refs/heads/master
Commit: 8c8ab0adc1333fb1463173fd192dea3963deaeee
Parents: abaccaa
Author: Justin Bertram <jbertram@apache.org>
Authored: Wed Jul 26 15:30:10 2017 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Jul 28 18:00:50 2017 -0400

----------------------------------------------------------------------
 .../activemq/artemis/ra/ActiveMQRaUtils.java       | 14 ++++++++++++--
 .../artemis/ra/ActiveMQResourceAdapter.java        |  2 +-
 .../tests/integration/ra/ResourceAdapterTest.java  | 17 +++++++++++++++++
 3 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8c8ab0ad/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java
index f67022e..bc2b42f 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import org.jgroups.JChannel;
 
@@ -190,7 +191,15 @@ public final class ActiveMQRaUtils {
    public static List<Map<String, Object>> parseConfig(final String config) {
       List<Map<String, Object>> result = new ArrayList<>();
 
-      String[] topElements = config.split(",");
+      /**
+       * Some configuration values can contain commas (e.g. enabledProtocols, enabledCipherSuites,
etc.).
+       * To support config values with commas, the commas in the values must be escaped (e.g.
"\\,") so that
+       * the commas used to separate configs for different connectors can still function
as designed.
+       */
+      String commaPlaceHolder = UUID.randomUUID().toString();
+      String replaced = config.replace("\\,", commaPlaceHolder);
+
+      String[] topElements = replaced.split(",");
 
       for (String topElement : topElements) {
          HashMap<String, Object> map = new HashMap<>();
@@ -205,7 +214,8 @@ public final class ActiveMQRaUtils {
                throw new IllegalArgumentException("Invalid expression " + element + " at
" + config);
             }
 
-            map.put(expression[0].trim(), expression[1].trim());
+            // put the commas back
+            map.put(expression[0].trim(), expression[1].trim().replace(commaPlaceHolder,
","));
          }
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8c8ab0ad/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
index 990d9e4..bd4b8c9 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
@@ -1605,7 +1605,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable
{
     *
     * @return The properties
     */
-   protected ActiveMQRAProperties getProperties() {
+   public ActiveMQRAProperties getProperties() {
       if (logger.isTraceEnabled()) {
          logger.trace("getProperties()");
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8c8ab0ad/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
index 7bc678a..c7a1474 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
@@ -637,6 +637,23 @@ public class ResourceAdapterTest extends ActiveMQRATestBase {
       assertTrue(endpoint.released);
    }
 
+   @Test
+   public void testConnectionParameterStringParsing() throws Exception {
+      ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
+      resourceAdapter.setConnectionParameters("enabledProtocols=TLS1\\,TLS1.2;sslEnabled=true");
+      assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(0).get("enabledProtocols"),
"TLS1,TLS1.2");
+      resourceAdapter.setConnectionParameters("enabledProtocols=TLS1\\,TLS1.2;sslEnabled=true,enabledProtocols=TLS1.3\\,TLS1.4\\,TLS1.5;sslEnabled=true");
+      assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(0).get("enabledProtocols"),
"TLS1,TLS1.2");
+      assertEquals(resourceAdapter.getProperties().getParsedConnectionParameters().get(1).get("enabledProtocols"),
"TLS1.3,TLS1.4,TLS1.5");
+
+      try {
+         resourceAdapter.setConnectionParameters("enabledProtocols=TLS1,TLS1.2;sslEnabled=true,enabledProtocols=TLS1,TLS1.2;sslEnabled=true");
+         fail("This should have failed");
+      } catch (Exception e) {
+         // ignore
+      }
+   }
+
    @Override
    public boolean useSecurity() {
       return false;


Mime
View raw message