From 6c792045c9927302bfe1aba4b5a961af77d67652 Mon Sep 17 00:00:00 2001 From: Big Andy <8012398+big-andy-coates@users.noreply.github.com> Date: Sat, 22 Oct 2022 23:49:55 +0100 Subject: [PATCH] Turn on quiet mode ...to avoid additional output in processes picking up the `JAVA_TOOL_OPTIONS`. Without quiet mode the process will output something like line below as its first line to stdout, which can cause problems in some situations, i.e. where the output is being consumed by another process. ``` Listening for transport dt_socket at address: 53880 ``` fixes: https://github.com/JetBrains/attachme/issues/11 --- agent/src/test/resources/container/Dockerfile | 2 +- example/docker-compose.yml | 4 ++-- installer.sh | 4 ++-- .../src/main/java/com/attachme/plugin/AttachmeInstaller.java | 2 +- plugin/src/main/resources/conf.sh | 2 +- readme.md | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/agent/src/test/resources/container/Dockerfile b/agent/src/test/resources/container/Dockerfile index 038c252..fcccf9a 100644 --- a/agent/src/test/resources/container/Dockerfile +++ b/agent/src/test/resources/container/Dockerfile @@ -7,4 +7,4 @@ COPY build/libs/attachme-agent.jar . COPY src/test/resources/ForkBomb.java . # Notifies the host at port 9090, debugger attaches to the container port 9091, so need to expose 9091 inside the host to be able to debug -CMD ["bash", "-c", "cd /app && javac ForkBomb.java && NO_WAIT=true JAVA_TOOL_OPTIONS='-javaagent:attachme-agent.jar=port:9090,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127.0.0.1:9091' java ForkBomb 0" ] +CMD ["bash", "-c", "cd /app && javac ForkBomb.java && NO_WAIT=true JAVA_TOOL_OPTIONS='-javaagent:attachme-agent.jar=port:9090,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,quiet=y,suspend=y,address=127.0.0.1:9091' java ForkBomb 0" ] diff --git a/example/docker-compose.yml b/example/docker-compose.yml index 251d86a..47c7b55 100644 --- a/example/docker-compose.yml +++ b/example/docker-compose.yml @@ -15,7 +15,7 @@ services: ports: - 5001:5001 environment: - JAVA_TOOL_OPTIONS: "-javaagent:attachme-agent.jar=port:7857,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:5001" + JAVA_TOOL_OPTIONS: "-javaagent:attachme-agent.jar=port:7857,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,quiet=y,suspend=y,address=0.0.0.0:5001" entrypoint: java EchoService 8081 client: @@ -29,5 +29,5 @@ services: ports: - 5002:5002 environment: - JAVA_TOOL_OPTIONS: "-javaagent:attachme-agent.jar=port:7857,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:5002" + JAVA_TOOL_OPTIONS: "-javaagent:attachme-agent.jar=port:7857,host:172.17.0.1 -agentlib:jdwp=transport=dt_socket,server=y,quiet=y,suspend=y,address=0.0.0.0:5002" entrypoint: java Client echoservice 8081 HelloWorld \ No newline at end of file diff --git a/installer.sh b/installer.sh index 8fd725a..1c49b93 100755 --- a/installer.sh +++ b/installer.sh @@ -10,7 +10,7 @@ if [ ! -f "${AGENT_PATH}" ]; then fi if [ ! -f "${HOME}/.attachme" ]; then { - echo "AM_JDWP_ARGS=\"\${JDWP_ARGS:=transport=dt_socket,server=y,suspend=y,address=*:0}\"" + echo "AM_JDWP_ARGS=\"\${JDWP_ARGS:=transport=dt_socket,server=y,suspend=y,quiet=y,address=*:0}\"" echo "echo Using JDWP arguments \${AM_JDWP_ARGS}" echo "export JAVA_TOOL_OPTIONS=\"-javaagent:${AGENT_PATH} -agentlib:jdwp=\${AM_JDWP_ARGS}\"" echo "echo \"AttachMe configured successfully\"" @@ -21,7 +21,7 @@ fi cat << EOF AttachMe installed successfully Usage example: - #(Optional) export JDWP_ARGS="transport=dt_socket,server=y,suspend=n,address=127.0.0.1:0" + #(Optional) export JDWP_ARGS="transport=dt_socket,server=y,suspend=n,quiet=y,address=127.0.0.1:0" source ~/.attachme java com.example.Application EOF \ No newline at end of file diff --git a/plugin/src/main/java/com/attachme/plugin/AttachmeInstaller.java b/plugin/src/main/java/com/attachme/plugin/AttachmeInstaller.java index 933749c..612a11f 100644 --- a/plugin/src/main/java/com/attachme/plugin/AttachmeInstaller.java +++ b/plugin/src/main/java/com/attachme/plugin/AttachmeInstaller.java @@ -66,7 +66,7 @@ private void printHelp() { "\t$ source ~/.attachme/conf.sh\n" + "\t$ java com.example.MyApp\n" + "In case you want to modify the port of AttachMe or java debugger (JDWP) arguments\n" + - "\t$ JDWP_ARGS=\"transport=dt_socket,server=y,suspend=y,address=127.0.0.1:0\" AM_PORT=9009 source ~/.attachme/conf.sh\n" + + "\t$ JDWP_ARGS=\"transport=dt_socket,server=y,suspend=y,quiet=y,address=127.0.0.1:0\" AM_PORT=9009 source ~/.attachme/conf.sh\n" + "For more details, questions or bug reports refer to https://github.com/JetBrains/attachme/\n" + "***********************************************************************\n"; log.info(help); diff --git a/plugin/src/main/resources/conf.sh b/plugin/src/main/resources/conf.sh index f96e57b..393678f 100644 --- a/plugin/src/main/resources/conf.sh +++ b/plugin/src/main/resources/conf.sh @@ -2,7 +2,7 @@ VERSION="@ATTACHME_VERSION@" JDWP_ADDR="${JDWP_ADDR:=127.0.0.1}" JDWP_PORT="${JDWP_PORT:=0}" -JDWP_ARGS="${JDWP_ARGS:=transport=dt_socket,server=y,suspend=y,address=${JDWP_ADDR}:${JDWP_PORT}}" +JDWP_ARGS="${JDWP_ARGS:=transport=dt_socket,server=y,suspend=y,quiet=y,address=${JDWP_ADDR}:${JDWP_PORT}}" AM_PORT="${AM_PORT:=7857}" AM_JAR="${AM_JAR:=${HOME}/.attachme/attachme-agent-${VERSION}.jar}" diff --git a/readme.md b/readme.md index 975634d..ef9cf6f 100644 --- a/readme.md +++ b/readme.md @@ -50,7 +50,7 @@ JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debu To fix it, try to configure AttachMe with port address 127.0.0.1, like this: ``` -JDWP_ARGS="transport=dt_socket,server=y,suspend=y,address=127.0.0.1:0" source ~/.attachme/conf.sh +JDWP_ARGS="transport=dt_socket,server=y,suspend=y,quiet=y,address=127.0.0.1:0" source ~/.attachme/conf.sh ``` AttachMe is not compatible with the JMX agent. If you are having problems running it with the auto generated SpringBoot run configuration, most likely disabling JMX will fix the problem.