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

3.2.5 rest协议使用apache-http-client出现NPE #12916

Closed
1 task
lucky-xin opened this issue Aug 16, 2023 · 2 comments · Fixed by #12984
Closed
1 task

3.2.5 rest协议使用apache-http-client出现NPE #12916

lucky-xin opened this issue Aug 16, 2023 · 2 comments · Fixed by #12984
Labels
type/bug Bugs to being fixed

Comments

@lucky-xin
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 3.2.5
  • Operating System version: MAC OS
  • Java version: 17

Steps to reproduce this issue

  1. 定义rest接口并配置client=apache-http-client
**
 * 文件管理服务接口
 *
 * @author chaoxin.lu
 * @since 2018/6/28
 */
@RequestMapping("/oss")
public interface FileSvc {

    /**
     * 获取文件
     *
     * @param bucket
     * @param key   
     * @return
     */
    @GetMapping
    @ResponseBody
    R<FileEntry> getObject(@RequestParam("bucket") String bucket,
                           @RequestParam("key") String key);

}
dubbo:
    protocol:
        id: ${DUBBO_PROTOCOL:rest}
        name: ${DUBBO_PROTOCOL:rest}
        client: ${DUBBO_CLIENT:apache-http-client}
        port: ${DUBBO_PORT:20895}
        server: ${DUBBO_PROTOCOL_SERVER:netty}
  1. 服务消费者如下
    image

Pls. provide [GitHub address] to reproduce this issue.

Expected Behavior

Actual Behavior

If there is an exception, please attach the exception trace:

Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.http.Header.getValue()" because the return value of "org.apache.http.client.methods.CloseableHttpResponse.getFirstHeader(String)" is null
	at org.apache.dubbo.remoting.http.restclient.HttpClientRestClient$1.getContentType(HttpClientRestClient.java:96)
	at org.apache.dubbo.rpc.protocol.rest.RestInvoker.lambda$doInvoke$0(RestInvoker.java:105)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
	at java.base/java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:887)
	at java.base/java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2325)
	at org.apache.dubbo.rpc.protocol.rest.RestInvoker.doInvoke(RestInvoker.java:87)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.doInvokeAndReturn(AbstractInvoker.java:243)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:187)
	... 97 more

NPE点如下
image
使用默认的okhttp则没有该问题
image

@lucky-xin lucky-xin added the type/bug Bugs to being fixed label Aug 16, 2023
@AlbumenJ
Copy link
Member

Would u pls try to fix it?

@lucky-xin
Copy link
Author

Would u pls try to fix it?

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants