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

ErrorDecoderInterceptor 不支持接口继承的 RetrofitClient #141

Open
achievec opened this issue Dec 6, 2022 · 5 comments
Open

ErrorDecoderInterceptor 不支持接口继承的 RetrofitClient #141

achievec opened this issue Dec 6, 2022 · 5 comments

Comments

@achievec
Copy link

achievec commented Dec 6, 2022

  • com.github.lianjiatech.retrofit.spring.boot.interceptor.ErrorDecoderInterceptor#intercept
    @Override
    @SneakyThrows
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Method method = Objects.requireNonNull(request.tag(Invocation.class)).method();
        RetrofitClient retrofitClient =
                AnnotatedElementUtils.findMergedAnnotation(method.getDeclaringClass(), RetrofitClient.class); // 如果接口有继承关系,这里返回 null,导致 NPE
        ErrorDecoder errorDecoder =
                AppContextUtils.getBeanOrNew(applicationContext, retrofitClient.errorDecoder());
       
@achievec
Copy link
Author

achievec commented Dec 6, 2022

interface A{

@GET("/hello")
Object hello();

}

@RetrofitClient(baseUrl = "urlB")
interface B extends A{

}


@RetrofitClient(baseUrl = "urlC")
interface C extends A{

}

@chentianming11
Copy link
Collaborator

这种情况,目前是不支持的,此时拿不到retrofitClient。

根本原因是retrofit不支持,已经向Retrofit提过相关issue了,等待后续retrofit支持。

@efemoney
Copy link

See prior issue at #109 (which I think should've been left open)

@chentianming11
Copy link
Collaborator

Versions 2.4.0 and 3.1.0 are already supported

@efemoney
Copy link

You should close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants