diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index ee2d39f8c5b..4266a5c61d2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -173,6 +173,11 @@ public class Response implements HttpServletResponse public void addCookie(HttpCookie cookie) { + if (StringUtil.isBlank(cookie.getName())) + { + throw new IllegalArgumentException("Cookie.name cannot be blank/null"); + } + if (getHttpChannel().getHttpConfiguration().isCookieCompliance(CookieCompliance.RFC2965)) addSetRFC2965Cookie( cookie.getName(), @@ -212,6 +217,11 @@ public class Response implements HttpServletResponse comment = null; } } + + if (StringUtil.isBlank(cookie.getName())) + { + throw new IllegalArgumentException("Cookie.name cannot be blank/null"); + } if (getHttpChannel().getHttpConfiguration().isCookieCompliance(CookieCompliance.RFC2965)) addSetRFC2965Cookie(cookie.getName(),