Skip to content

拦截okhttp.RealCall的execute方法报java.lang.LinkageError异常 #133

@wangmingxiang

Description

@wangmingxiang

操作环境

... ...
操作系统 Windows 10
JVM版本 Oracle JDK 1.8.0_131
沙箱容器版本 1.1.2
沙箱API版本 1.1.2

问题描述

sandbox 1.1.2版本测试
springboot版本:1.5.9.RELEASE
okhttp3版本:3.12.1
拦截okhttp3.RealCallexecute方法报java.lang.LinkageError错误

重现步骤

  1. 拦截okhttp3.RealCall类的execute方法
  2. 测试代码使用springboot暴露http接口,在接口内调用okhttp3发送http请求
  3. 出现java.lang.LinkageError

相关代码如下:
sandbox代码:

new EventWatchBuilder(moduleEventWatcher)
            .onClass("okhttp3.RealCall")
            .onBehavior("execute")
            .onWatch(new AdviceListener() {
                
                @Override
                public void before(Advice advice) throws Throwable {
                    
                }
                
                @Override
                public void afterReturning(Advice advice) throws Throwable {
                    
                }
                
                @Override
                public void afterThrowing(Advice advice) throws Throwable {
                    
                }
                
            });

springboot代码:

@GetMapping("/okHttp")
public String testOkHttp() throws IOException {
    OkHttpClient client = new OkHttpClient.Builder().build();
    Request request = new Request.Builder()
            .url("http://localhost:8080/api").build();
    okhttp3.Response execute = client.newCall(request).execute();
    return execute.body().string();
}

附件
error.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions