Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespaces #2109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kalinchan
Copy link

Credit to @breakponchito

See payara/Payara#4551

The following block of code process the arguments to prepare the execution of the broker:

openmq/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java at master · eclipse-ee4j/openmq

the following block:

   if (brokerExtraArgs != null && !("".equals(brokerExtraArgs))) {
        StringTokenizer st = new StringTokenizer(brokerExtraArgs, " ");
        while (st.hasMoreTokens()) {
            String t = st.nextToken();
            v.add(t);
        }
    }

process the brokerArgs and separates considering the delimiter as a white space, that is why when sending the following attribute:

brokerArgs= -jrehome "C:\Program Files\Java\jdk-11.0.12"
is processed as follows:

-jrehome
"C:\Program
Files\Java\jdk-11.0.12"
this is saved on a Vector that is processed after

then the following block of code validates the sequence of parameters. The expected case is waiting the path after the property -jrehome but after the previous separation we have two values after the property:

openmq/mq/main/mq-broker/broker-core/src/main/java/com/sun/messaging/jmq/jmsserver/Broker.java at master · eclipse-ee4j/openmq

that is why the following exception is thrown because the third position is not expected

openmq/mq/main/mq-broker/broker-core/src/main/java/com/sun/messaging/jmq/jmsserver/Broker.java at master · eclipse-ee4j/openmq

[2021-10-20T17:49:14.044-0500] [Payara 5.2021.9-SNAPSHOT] [SEVERE] [] [] [tid: _ThreadID=150 _ThreadName=JMS_PROXY_default_JMS_host-kernel(1) SelectorRunner] [timeMillis: 1634770154044] [levelValue: 1000] [[
java.lang.IllegalArgumentException: unknown option Files\Java\jdk-11.0.12"

private static final Set<String> parameterNames;

static {
parameterNames = Set.of("-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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think all parameters listed here are required, for example -debug or -port - do they support values with spaces?

Copy link
Author

@kalinchan kalinchan Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I removed the right parameters.

v.add(s);
continue;
}
builderValue.append(s + " ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that, I'm getting trailing space in final element that was not present in the input.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants