From 31d3f2f8de75babb5a1944842c86cefd7b282d6c Mon Sep 17 00:00:00 2001 From: Nikita Salnikov-Tarnovski Date: Fri, 11 Jun 2021 15:12:38 +0300 Subject: [PATCH] Update ByteBuddy (#3254) * Update ByteBuddy * spotless --- dependencyManagement/dependencyManagement.gradle.kts | 2 +- .../io/opentelemetry/javaagent/tooling/HelperInjector.java | 3 ++- .../tooling/bytebuddy/AgentCachingPoolStrategy.java | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dependencyManagement/dependencyManagement.gradle.kts b/dependencyManagement/dependencyManagement.gradle.kts index a105a553367b..d3e510b490ed 100644 --- a/dependencyManagement/dependencyManagement.gradle.kts +++ b/dependencyManagement/dependencyManagement.gradle.kts @@ -53,7 +53,7 @@ val DEPENDENCY_SETS = listOf( ), DependencySet( "net.bytebuddy", - "1.10.18", + "1.11.2", listOf("byte-buddy", "byte-buddy-agent") ), DependencySet( diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java index 73653beaf536..99bc5f45cb59 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java @@ -225,8 +225,9 @@ private void ensureModuleCanReadHelperModules(JavaModule target) { if (!target.canRead(helperModule)) { log.debug("Adding module read from {} to {}", target, helperModule); - target.modify( + ClassInjector.UsingInstrumentation.redefineModule( AgentInstaller.getInstrumentation(), + target, Collections.singleton(helperModule), Collections.emptyMap(), Collections.emptyMap(), diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bytebuddy/AgentCachingPoolStrategy.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bytebuddy/AgentCachingPoolStrategy.java index f86d99380a86..c01ebe921d58 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bytebuddy/AgentCachingPoolStrategy.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bytebuddy/AgentCachingPoolStrategy.java @@ -100,6 +100,12 @@ public final TypePool typePool(ClassFileLocator classFileLocator, ClassLoader cl return createCachingTypePool(loaderHash, loaderRef, classFileLocator); } + @Override + public final TypePool typePool( + ClassFileLocator classFileLocator, ClassLoader classLoader, String name) { + return typePool(classFileLocator, classLoader); + } + private TypePool.CacheProvider createCacheProvider( int loaderHash, WeakReference loaderRef) { return new SharedResolutionCacheAdapter(loaderHash, loaderRef, sharedResolutionCache);