stork icon indicating copy to clipboard operation
stork copied to clipboard

[: Illegal number: 09:52:08:460 when using JAVA_TOOL_OPTIONS with a java agent

Open froque opened this issue 1 year ago • 0 comments

We are using Datadog java agent in JAVA_TOOL_OPTIONS environment variable: export JAVA_TOOL_OPTIONS="-javaagent:dd-java-agent.jar -Ddd.writer.type=LoggingWriter"

This means that when stork tries to discover java versions, the java version parsing algorithm sometimes fails due to the extra output from datadog java agent:

❯ export JAVA_TOOL_OPTIONS="-javaagent:dd-java-agent.jar -Ddd.writer.type=LoggingWriter" 
❯ java -version 2>&1 | grep "version" | awk '{print $3}' | tr -d \" 
10:16:24:649
10:16:24:650
10:16:24:650
22.0.1

If the output from datadog java agent is the last and not the java version, the bash script fails with:

❯ ./stork-demo-hellod        
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
./stork-demo-hellod: 496: [: Illegal number: 14:14:03:228
Unable to find Java runtime on system with version >= 1.6
Try running 'sudo apt-get install openjdk-6-jre-headless' or
Visit http://java.com to download and install one for your system

froque avatar Jun 11 '24 09:06 froque