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

Cannot parse Java version if JAVA_TOOL_OPTIONS or JDK_JAVA_OPTIONS environment variable is set #117

Open
wiebeck opened this issue Sep 8, 2022 · 1 comment

Comments

@wiebeck
Copy link

wiebeck commented Sep 8, 2022

We noticed that our Quarkus containers (which use run-java.sh v1.3.8) running on Kubernetes spit out a lot of the following errors when starting up:

/deployments/run-java.sh: line 332: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 380: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 420: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 457: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 332: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 380: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 420: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected
/deployments/run-java.sh: line 457: [: Picked up JAVA_TOOL_OPTIONS: -javaagent:/appinsights/applicationinsights-agent.jar: integer expression expected

Background: we want to inject the MS Azure Application Insights Agent into all our Java apps without the need to bundle the agent into the Quarkus container, so we inject a sidecar container that downloads the agent jar file and sets the JAVA_TOOL_OPTIONS environment variable.

Now if you set either JAVA_TOOL_OPTIONS or JDK_JAVA_OPTIONS environment variables the java process will print out a line telling that it picked up this environment variable when starting:

$ export JAVA_TOOL_OPTIONS=-Dfoo=bar
$ java -version
Picked up JAVA_TOOL_OPTIONS: -Dfoo=bar
openjdk version "11.0.16.1" 2022-08-12
OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)

This breaks the code in run-java.sh which determines the Java version so we get a lot of error messages and probably other side effects.

Check out pinterest/ktlint#1544 to see how others fixed this.

@rhuss
Copy link
Contributor

rhuss commented Sep 19, 2022

Thanks for pointing that out, but unfortunately, I don't have any time to spend on java-run-sh. Happy to integrate a PR though if you are fancy to provide one.

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

No branches or pull requests

2 participants