Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java agent Instrumentation breaks OKhttp3 #324

Closed
moodgorning opened this issue Jun 11, 2021 · 6 comments · Fixed by #326
Closed

java agent Instrumentation breaks OKhttp3 #324

moodgorning opened this issue Jun 11, 2021 · 6 comments · Fixed by #326
Labels
bug Something isn't working as designed/intended

Comments

@moodgorning
Copy link

Description

We are using Apollo GraphQL java client with okhttp3 as the HTTP module. installing the java agent and starting the app with it leads to the following error:

Exception in thread "Apollo Dispatcher" java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(okhttp3.MediaType, okio.ByteString)'
com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor.httpPostCall(ApolloServerInterceptor.kt:130)
com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor.executeHttpCall(ApolloServerInterceptor.kt:84)
com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$interceptAsync$1.run(ApolloServerInterceptor.kt:66)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)

I have tried multiple versions of okhttp, down to 3.14.9 to no avail

Expected Behavior

no exception to be thrown and okhttp to work correctly

Troubleshooting or NR Diag results

Steps to Reproduce

I followed the java logback config guide. trouble starts as as soon as I start our app with the -javaagent:newrelic/newrelic.jar in the command line

Your Environment

running on OPenJDK on a raspberry PI3B+
project dependencies:

io.sentry
sentry
1.7.30


org.projectlombok
lombok
1.18.16
provided

    <dependency>
        <groupId>com.auth0</groupId>
        <artifactId>auth0</artifactId>
        <version>1.19.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.sensorflow.wrapper</groupId>
        <artifactId>loraGwWrapper</artifactId>
        <version>0.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>
    <dependency>
        <groupId>org.danilopianini</groupId>
        <artifactId>gson-extras</artifactId>
        <version>0.2.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.30.1</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.18</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-commons</artifactId>
        <version>1.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.6.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>5.6.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-engine</artifactId>
        <version>1.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.30</version>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.newrelic.logging</groupId>
        <artifactId>logback</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
    </dependency>
    <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy-agent</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-core</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>2.5.1</version>
    </dependency>

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>${powermock.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito2</artifactId>
        <version>${powermock.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.apollographql.apollo</groupId>
        <artifactId>apollo-runtime</artifactId>
        <version>2.5.3</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okio</groupId>
        <artifactId>okio</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-reflect</artifactId>
        <version>1.4.30</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.9.1</version>
    </dependency>

Additional context

it seems to be related to the changes mentioned here around the Extension Functions
https://square.github.io/okhttp/upgrading_to_okhttp_4/
Searching around the web reveals that okhttp and new relic seem to be causing trouble frequently e.g.
square/okhttp#6277

@moodgorning moodgorning added the bug Something isn't working as designed/intended label Jun 11, 2021
@benlei-gfm
Copy link

benlei-gfm commented Jun 11, 2021

We're seeing a similar issue, but with a different method:

Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okhttp3.RequestBody.writeTo(Lokio/BufferedSink;)V
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested
....

@baltov
Copy link

baltov commented Jun 13, 2021

We have similar issue with new ver 7.0.0, logLevel is BODY

retrofit.version: 2.9.0
okhttp.version: 3.14.9
"description" : "Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okhttp3.ResponseBody.source()Lokio/BufferedSource;", "stackTrace" : "java.lang.NoSuchMethodError: okhttp3.ResponseBody.source()Lokio/BufferedSource;,\tat okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:250),\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)"

@moodgorning
Copy link
Author

I have tried to reproduce this issue on my MAC, but it seems to work fine there. Maybe it's OS related. The Raspberry Pi also runs a 32BIt OS.

@meiao
Copy link
Contributor

meiao commented Jun 14, 2021

@moodgorning indeed, it is not reproducible on Macs. But I was able to reproduced in a 64bit VM running Linux.

@moodgorning
Copy link
Author

Works fine now, thanks much

@meiao
Copy link
Contributor

meiao commented Jun 17, 2021

To anyone who had this problem, this has been fixed on release 7.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as designed/intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants