painAdmin opened a new issue, #15982: URL: https://github.com/apache/dubbo/issues/15982
### Pre-check - [x] I am sure that all the content I provide is in English. ### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues. ### Apache Dubbo Component Java SDK (apache/dubbo) ### Dubbo Version Dubbo:3.2.2, jdk:java version "1.8.0_191", CentOS Linux release 7.9.2009 (Core) ### Steps to reproduce this issue 背景:使用springboot+dubbo,搭建一个web服务,协议为tri协议,定义controller接口为 Background: Building a web service using Spring Boot and Dubbo, with the tri protocol, and defining the controller interface as follows. @DubboService public class IndexApi implements IndexApiService { @RequestMapping("/api/index") @Override public String index(HttpServletRequest request, HttpServletResponse response) { return "ok"+getCookie(request,"test"); } } /** * 根据cookie名字获取value * Retrieve value based on cookie name */ public String getCookie(HttpServletRequest request, String name) { try { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (name.equals(cookie.getName())) { return cookie.getValue(); } } } } catch (Exception e) { logger.error("error,", e); } return null; } 复现过程: Reproduction process: 当请求中无cookie时候,会报NullPointerException 异常,堆栈如下 When the request does not contain cookies, a NullPointerException will be thrown, as shown in the stack trace below. java.lang.NullPointerException: header at io.netty.util.internal.ObjectUtil.checkNotNull(ObjectUtil.java:39) at io.netty.handler.codec.http.cookie.ServerCookieDecoder.decode(ServerCookieDecoder.java:89) at io.netty.handler.codec.http.cookie.ServerCookieDecoder.decodeAll(ServerCookieDecoder.java:70) at org.apache.dubbo.remoting.http12.HttpUtils.decodeCookies(HttpUtils.java:78) at org.apache.dubbo.remoting.http12.message.DefaultHttpRequest.cookies(DefaultHttpRequest.java:181) at org.apache.dubbo.rpc.protocol.tri.rest.support.servlet.ServletHttpRequestAdapter.getCookies(ServletHttpRequestAdapter.java:79) ### What you expected to happen 在org.apache.dubbo.remoting.http12.HttpUtils 中方法: public static List<HttpCookie> decodeCookies(String value) { List<HttpCookie> cookies = new ArrayList<>(); for (Cookie c : ServerCookieDecoder.LAX.decodeAll(value)) { cookies.add(new HttpCookie(c.name(), c.value())); } return cookies; } ServerCookieDecoder.LAX.decodeAll(value) The method is incompatible with cases where the value is empty, resulting in an error. ### Anything else _No response_ ### Are you willing to submit a pull request to fix on your own? - [x] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
