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

[BUG] Invalid JMX options causes silent exit #1

Open
XA21X opened this issue Jan 22, 2022 · 3 comments
Open

[BUG] Invalid JMX options causes silent exit #1

XA21X opened this issue Jan 22, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@XA21X
Copy link
Member

XA21X commented Jan 22, 2022

Describe the bug
Invalid --jmx- prefixed options causes the program to exit with no error message.

To Reproduce
java -jar minotaur.jar -s some-dc --jmx-bad

Expected behavior
Like non-JMX options, it should print the error Unknown option: '--jmx-bad' followed by usage instructions.

System and versions:

  • macOS Monterey 12.1 on M1 Pro (arm64)
  • OpenJDK 64-Bit Server VM Zulu11.52+13-CA (build 11.0.13+8-LTS, mixed mode)
  • Minotaur 1.0.2-SNAPSHOT (current master)
@XA21X XA21X added the bug Something isn't working label Jan 22, 2022
@XA21X
Copy link
Member Author

XA21X commented Jan 22, 2022

Initial investigation

The picocli.CommandLine.DefaultExceptionHandler#internalHandleParseException looked like it should be sufficient for printing a suitable error message, but why isn't it working? I double checked it's writing to the PrintWriter that's backed by the correct System.err object. It turns out the internal handler writes without flushing, and the PrintWriter we provide from com.instaclustr.picocli.CLIApplication#execute(picocli.CommandLine, java.lang.String...) does not have auto-flush turned on, so the error output gets lost.

While debugging, I could manually flush the writers to obtain the output:

Unknown option: '--jmx-bad'
Possible solutions: --jmx-service, --jmx-user, --jmx-password, --jmx-credentials, --jmx-truststore, --jmx-truststore-password, --jmx-keystore, --jmx-keystore-password, --jmx-client-auth

Proposed Solution

Enable auto-flushing for both PrintWriters at https://github.com/instaclustr/instaclustr-commons/blob/94294f6dea4c62cbfcae34de4ea41051aa02356e/src/main/java/com/instaclustr/picocli/CLIApplication.java#L21

@smiklosovic
Copy link
Collaborator

thanks @XA21X , I ll merge it soon.

@smiklosovic
Copy link
Collaborator

fixed here, (not released yet) instaclustr/instaclustr-commons#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants