From 35746aaf5a3e6eab9181fedb37fd8cc00793469c Mon Sep 17 00:00:00 2001 From: aofall <10182210+aofall@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:22:21 +0800 Subject: [PATCH] Fix rest protocol NPE when using apache-http-client (#12916) (#12984) --- .../dubbo/remoting/http/restclient/HttpClientRestClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/HttpClientRestClient.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/HttpClientRestClient.java index 0344a4aab9..f8f85411af 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/HttpClientRestClient.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/HttpClientRestClient.java @@ -93,7 +93,8 @@ public class HttpClientRestClient implements RestClient { future.complete(new RestResult() { @Override public String getContentType() { - return response.getFirstHeader("Content-Type").getValue(); + Header header = response.getFirstHeader("Content-Type"); + return header == null ? null : header.getValue(); } @Override