From a32e3a2091a12c0b3d0f9dfd7a7ae4c4d144da52 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 4 May 2016 10:53:05 +1000 Subject: [PATCH] avoided NPE in example --- .../main/java/org/eclipse/jetty/embedded/Http2Server.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java index 28f8547a1ef..0502fb2f65c 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java @@ -179,8 +179,10 @@ public class Http2Server content+="session="+session.getId()+(session.isNew()?"(New)\n":"\n"); content+="date="+new Date()+"\n"; - for (Cookie c : request.getCookies()) - content+="cookie "+c.getName()+"="+c.getValue()+"\n"; + Cookie[] cookies = request.getCookies(); + if (cookies!=null && cookies.length>0) + for (Cookie c : cookies) + content+="cookie "+c.getName()+"="+c.getValue()+"\n"; response.setContentLength(content.length()); response.getOutputStream().print(content);