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.
What does this PR do?
Fixes #1450
Checklist
I have added tests that would fail without this fixI've tried creating a test for this (see 9dcaff3) but gave up.
The problem is that the instrumented class will be defined by the system class loader which is also a parent of the
IndyPluginClassLoaderas it’s the agent class loader in unit tests. Thus, theIndyPluginClassLoaderwill load the instrumented class from the system class loader before trying to load from the custom class loader. That’s because we want to give precedence to load classes in the agent class loader.This results in a linkage error as the class resolved by the
IndyPluginClassLoaderis not the same as the one from the custom class loader whose parent is the bootstrap class loader.The test also requires that the signature of the advice contains a class that's defined in two different class loader hierarchies. But that class must not be within the package
co.elastic.apm.*as these are not available in production in the context of the instrumented methods.