Set POOL_ONLY DescriptionStrategy for ByteBuddy
This makes sure no classes are loaded during instrumentation transformation which allows us to safely instrument depndent classes.
This commit is contained in:
parent
b6118f0397
commit
4ae9263e1c
|
@ -42,6 +42,7 @@ public class AgentInstaller {
|
||||||
new AgentBuilder.Default()
|
new AgentBuilder.Default()
|
||||||
.disableClassFormatChanges()
|
.disableClassFormatChanges()
|
||||||
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
|
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
|
||||||
|
.with(AgentBuilder.DescriptionStrategy.Default.POOL_ONLY)
|
||||||
.with(new LoggingListener())
|
.with(new LoggingListener())
|
||||||
.with(new DDLocationStrategy())
|
.with(new DDLocationStrategy())
|
||||||
.ignore(any(), skipClassLoader())
|
.ignore(any(), skipClassLoader())
|
||||||
|
|
|
@ -21,11 +21,11 @@ public class ReferenceMatcher {
|
||||||
private final Reference[] references;
|
private final Reference[] references;
|
||||||
private final Set<String> helperClassNames;
|
private final Set<String> helperClassNames;
|
||||||
|
|
||||||
public ReferenceMatcher(Reference... references) {
|
public ReferenceMatcher(final Reference... references) {
|
||||||
this(new String[0], references);
|
this(new String[0], references);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceMatcher(String[] helperClassNames, Reference[] references) {
|
public ReferenceMatcher(final String[] helperClassNames, final Reference[] references) {
|
||||||
this.references = references;
|
this.references = references;
|
||||||
this.helperClassNames = new HashSet<>(Arrays.asList(helperClassNames));
|
this.helperClassNames = new HashSet<>(Arrays.asList(helperClassNames));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class ReferenceMatcher {
|
||||||
* @param loader Classloader to validate against (or null for bootstrap)
|
* @param loader Classloader to validate against (or null for bootstrap)
|
||||||
* @return true if all references match the classpath of loader
|
* @return true if all references match the classpath of loader
|
||||||
*/
|
*/
|
||||||
public boolean matches(ClassLoader loader) {
|
public boolean matches(final ClassLoader loader) {
|
||||||
return getMismatchedReferenceSources(loader).size() == 0;
|
return getMismatchedReferenceSources(loader).size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class ReferenceMatcher {
|
||||||
mismatches = mismatchCache.get(loader);
|
mismatches = mismatchCache.get(loader);
|
||||||
if (null == mismatches) {
|
if (null == mismatches) {
|
||||||
mismatches = new ArrayList<>(0);
|
mismatches = new ArrayList<>(0);
|
||||||
for (Reference reference : references) {
|
for (final Reference reference : references) {
|
||||||
// Don't reference-check helper classes.
|
// Don't reference-check helper classes.
|
||||||
// They will be injected by the instrumentation's HelperInjector.
|
// They will be injected by the instrumentation's HelperInjector.
|
||||||
if (!helperClassNames.contains(reference.getClassName())) {
|
if (!helperClassNames.contains(reference.getClassName())) {
|
||||||
|
|
Loading…
Reference in New Issue