Skip to content

Commit

Permalink
Fix OkHttp v3 instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
romtsn committed Jul 18, 2022
1 parent b86b830 commit 67041c3
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -11,7 +11,7 @@ import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.MethodVisitor

class OkHttp : ClassInstrumentable {
override val fqName: String get() = "okhttp3.internal.connection.RealCall"
override val fqName: String get() = "RealCall"

override fun getVisitor(
instrumentableContext: ClassContext,
Expand All @@ -25,6 +25,12 @@ class OkHttp : ClassInstrumentable {
methodInstrumentables = listOf(ResponseWithInterceptorChain()),
parameters = parameters
)

// OkHttp has renamed the class in v4, hence we are looking for both old and new package names
// https://github.com/square/okhttp/commit/3d3b0f64005f7d2dd7cde80a9eaf665f8df86fb6#diff-e46bb5c1117393fbfb8cd1496fc4a2dcfcd6fcf70d065c50be83ce9215b2ec7b
override fun isInstrumentable(data: ClassContext): Boolean =
data.currentClassData.className == "okhttp3.internal.connection.RealCall" ||
data.currentClassData.className == "okhttp3.RealCall"
}

class ResponseWithInterceptorChain : MethodInstrumentable {
Expand Down

0 comments on commit 67041c3

Please sign in to comment.