Fix "URI is not hierarchical" during runtime attachment#359
Conversation
…ing runtime attachment
trask
left a comment
There was a problem hiding this comment.
is there a way to know whether copying is needed, and only copy in that case?
| try { | ||
| ByteBuddyAgent.attach(javaagentFile, getPid()); | ||
| } finally { | ||
| agentFileProvider.deleteTempDir(); |
There was a problem hiding this comment.
I would think that the JVM would still need access to the jar file for lazy loading additional classes? (in which case we could delete on exit instead)
There was a problem hiding this comment.
Not sure because the Javadoc of Byte Buddy's attach(File agentJar, String processId) method says "This operation blocks until the attachment is complete". In case of doubt, I will delete in exit.
The problem has appeared when the application was packaged as a jar file (I expect the same problem with a war file). The only solution I have found is to use a temp jar file (I have tried to write code with real path but without success). The same thing is done in Elastic agent. We could use a
|
|
makes sense, we may want to revisit later due to users on read-only file systems, but I agree with keeping it simple for now |
We may use the |
| } | ||
|
|
||
| private static void deleteTempDirOnJvmExit(Path tempDirPath, Path tempAgentJarPath) { | ||
| if (tempDirPath != null && tempAgentJarPath != null) { |
There was a problem hiding this comment.
can these be null? if so, let's add @Nullable to the params
There was a problem hiding this comment.
This can't be null but i was afraid by build checks 😅
|
I pushed spotlessApply 👍 |
Thank you! Maybe it would be possible to automatically add a spotless:apply commit in the CI |
When the runtime attachment feature was used with a Spring Boot application (jar), the runtime attachement dit not work and the following stack trace appeared:
This PR fixes the issue.