From 9d864a7441677ab29154fd013659874c485dc807 Mon Sep 17 00:00:00 2001 From: Alfonso Valdez Date: Mon, 25 Oct 2021 23:57:04 -0500 Subject: [PATCH 1/3] FISH-28: fix for openMQ white spaces on paths --- .../jms/blc/EmbeddedBrokerRunner.java | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java index 627fe9c1a..ea76dcda5 100644 --- a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java +++ b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java @@ -40,10 +40,7 @@ package com.sun.messaging.jms.blc; -import java.util.Enumeration; -import java.util.Properties; -import java.util.StringTokenizer; -import java.util.Vector; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -86,6 +83,18 @@ public class EmbeddedBrokerRunner protected static transient final String _lgrMID_ERR = _lgrMIDPrefix + "3001: "; protected static transient final String _lgrMID_EXC = _lgrMIDPrefix + "4001: "; + private static Set parameterNames; + + static { + parameterNames = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("-loglevel", "-save", "-shared", + "-debug", "-dbuser", "-dbpassword", "-dbpwd", "-diag", "-name", "-port", "-nobind", "-metrics", "-password", + "-pwd", "-ldappassword", "-ldappwd", "-read-stdin", "-passfile", "-backup", "-restore", "-cluster", + "-force", "-silent", "-s", "-ttyerrors", "-te", "-tty", "-D", "-varhome", "-jmqvarhome", "-imqhome", + "-libhome", "-javahome", "-jrehome", "-bgnd", "-init", "-version", "-v", "-ntservice", "-adminkeyfile", + "-help", "-h", "-remove", "-reset", "-upgrade-store-nobackup", "-useRmiRegistry", "-startRmiRegistry", + "-rmiRegistryPort", "-activateServices"))); + } + public EmbeddedBrokerRunner( String brokerTypeArgIgnored, String brokerInstanceName, String brokerBindAddress, int brokerPort, String brokerHomeDir, String brokerLibDir, String brokerVarDir, String brokerJavaDir, @@ -212,11 +221,15 @@ private String[] assembleBrokerArgs(String brokerInstanceName, Vector v = new Vector(); //Add extra args first; explicit config will override args - if (brokerExtraArgs != null && !("".equals(brokerExtraArgs)) ) { + if (brokerExtraArgs != null && !("".equals(brokerExtraArgs))) { StringTokenizer st = new StringTokenizer(brokerExtraArgs, " "); - while (st.hasMoreTokens()) { - String t = st.nextToken(); - v.add(t); + if (st.countTokens() > 2) { + processBrokerExtraArgs(st, v); + } else { + while (st.hasMoreTokens()) { + String t = st.nextToken(); + v.add(t); + } } } @@ -272,6 +285,32 @@ private String[] assembleBrokerArgs(String brokerInstanceName, return brokerArgs; } + /** + * This method separates the parameter names from the values considering blank spaces + * + * @param st StrinngTokenaziser containing the available tokens + * @param v Reference of the Vector object to save the parameter and the value in consecutive order + */ + public static void processBrokerExtraArgs(StringTokenizer st, Vector v) { + StringBuffer bufferValue = new StringBuffer(); + while (st.hasMoreTokens()) { + String s = st.nextToken(); + if (s.contains("-") && parameterNames.contains(s)) { + if (bufferValue.length() > 0) { + v.add(bufferValue.toString()); + bufferValue.delete(0, bufferValue.length()); + } + v.add(s); + continue; + } + bufferValue.append(s + " "); + } + + if (bufferValue.length() > 0) { + v.add(bufferValue.toString()); + } + } + /** * Create the in-JVM broker instance * From 3286444c3140d115a25d04ee0f290f35847a4e41 Mon Sep 17 00:00:00 2001 From: Alfonso Valdez Date: Tue, 26 Oct 2021 00:03:01 -0500 Subject: [PATCH 2/3] FISH-28: update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 59dd9685c..7e0a0463d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/target/** # Ignore examples .class **/src/share/java/examples/**/*.class +*.iml +.idea \ No newline at end of file From 7a41c9d296ed4d98616be1453eaeb8562bf5ab8c Mon Sep 17 00:00:00 2001 From: Alfonso Valdez Date: Tue, 26 Oct 2021 09:05:51 -0500 Subject: [PATCH 3/3] FISH-28: fix for comments on the PR --- .../jms/blc/EmbeddedBrokerRunner.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java index ea76dcda5..c712bfeda 100644 --- a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java +++ b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java @@ -288,26 +288,26 @@ private String[] assembleBrokerArgs(String brokerInstanceName, /** * This method separates the parameter names from the values considering blank spaces * - * @param st StrinngTokenaziser containing the available tokens + * @param st StringTokenizer containing the available tokens * @param v Reference of the Vector object to save the parameter and the value in consecutive order */ - public static void processBrokerExtraArgs(StringTokenizer st, Vector v) { - StringBuffer bufferValue = new StringBuffer(); + private static void processBrokerExtraArgs(StringTokenizer st, Vector v) { + StringBuilder builderValue = new StringBuilder(); while (st.hasMoreTokens()) { String s = st.nextToken(); - if (s.contains("-") && parameterNames.contains(s)) { - if (bufferValue.length() > 0) { - v.add(bufferValue.toString()); - bufferValue.delete(0, bufferValue.length()); + if (parameterNames.contains(s)) { + if (builderValue.length() > 0) { + v.add(builderValue.toString()); + builderValue.delete(0, builderValue.length()); } v.add(s); continue; } - bufferValue.append(s + " "); + builderValue.append(s + " "); } - if (bufferValue.length() > 0) { - v.add(bufferValue.toString()); + if (builderValue.length() > 0) { + v.add(builderValue.toString()); } }