TS-46443 Locate the agent's JAR without relying on its code source - #979
Merged
Merged
Conversation
The profiler read its installation directory from its own CodeSource to look for a teamscale.properties file next to the agent's JAR. IntelliJ's PathClassLoader records no location for a JAR appended for instrumentation, so CodeSource.getLocation() returned null and the resulting NullPointerException escaped premain, which aborts the JVM during startup. A location that names something other than a local file, such as a JAR nested in another one, ends in the same abort, as Paths.get rejects every scheme but file. Fall back to the JAR named by the -javaagent argument, which premain already reads for its warning about other agents.
1 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses issue TS-46443
The profiler read its installation directory from its own
CodeSourceto look for ateamscale.propertiesfile next to the agent's JAR. A class loader that records no location, or nolocal file, for that JAR made
premainthrow, and apremainthat throws aborts the JVM duringstartup. IntelliJ's
PathClassLoaderis one such class loader, so the profiler could not beattached to the test JVM of an IntelliJ plug-in at all.
It now falls back to the JAR named by the
-javaagentargument, whichpremainalready reads forits warning about other agents.
Verified end to end outside this repository: with this change the Teamscale Gradle plugin records
test-wise coverage for our own IntelliJ plug-in, 314 tests with coverage. That path additionally
needs the fix for TS-48018, which follows in a separate pull request.