NullPointer exception in cookies() method of HttpSupport:
Caused by: java.lang.NullPointerException
at org.javalite.activeweb.HttpSupport.cookies(HttpSupport.java:827)
at app.controllers.LoginController.index(LoginController.java:90)
at sun.reflect.GeneratedMethodAccessor318.invoke(Unknown Source)
Code:
/**
* Returns collection of all cookies browser sent.
*
* @return collection of all cookies browser sent.
*/
public List<Cookie> cookies(){
javax.servlet.http.Cookie[] servletCookies = Context.getHttpRequest().getCookies();
List<Cookie> cookies = new ArrayList<Cookie>();
for (javax.servlet.http.Cookie servletCookie: servletCookies) { // --- NPE
Cookie cookie = Cookie.fromServletCookie(servletCookie);
cookies.add(cookie);
}
return cookies;
}
HTTP Servlet documentation says that HttpServletRequest may return null within
getCookies method:
/**
*
* Returns an array containing all of the <code>Cookie</code>
* objects the client sent with this request.
* This method returns <code>null</code> if no cookies were sent.
*
* @return an array of all the <code>Cookies</code>
* included with this request, or <code>null</code>
* if the request has no cookies
*
*
*/
public Cookie[] getCookies();
Original issue reported on code.google.com by ipolevoy@gmail.com on 5 Mar 2012 at 9:46
Original issue reported on code.google.com by
ipolevoy@gmail.com
on 5 Mar 2012 at 9:46