Author: chris.laprun(a)jboss.com
Date: 2010-04-14 08:00:52 -0400 (Wed, 14 Apr 2010)
New Revision: 2632
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/handler/CookieUtil.java
Log:
- GTNWSRP-23: Fixed handling of max age.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/handler/CookieUtil.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/handler/CookieUtil.java 2010-04-14
11:58:38 UTC (rev 2631)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/handler/CookieUtil.java 2010-04-14
12:00:52 UTC (rev 2632)
@@ -39,7 +39,7 @@
public class CookieUtil
{
private static final RFC2109Spec cookieParser = new RFC2109Spec();
- private static final Logger log =
LoggerFactory.getLogger(RequestHeaderClientHandler.class);
+ private static final Logger log = LoggerFactory.getLogger(CookieUtil.class);
public static final String SET_COOKIE = "Set-Cookie";
public static final String COOKIE = "Cookie";
@@ -133,15 +133,23 @@
result.setComment(cookie.getComment());
result.setDomain(cookie.getDomain());
- long maxAgeLong = cookie.getExpiryDate().getTime() - new Date().getTime();
+ Date expiryDate = cookie.getExpiryDate();
int maxAge;
- if (maxAgeLong >= Integer.MAX_VALUE)
+ if (expiryDate != null)
{
- maxAge = Integer.MAX_VALUE;
+ long maxAgeLong = expiryDate.getTime() - new Date().getTime();
+ if (maxAgeLong >= Integer.MAX_VALUE)
+ {
+ maxAge = Integer.MAX_VALUE;
+ }
+ else
+ {
+ maxAge = (int)maxAgeLong;
+ }
}
else
{
- maxAge = (int)maxAgeLong;
+ maxAge = -1; // to specify that cookie should not be persisted but removed with
the session
}
result.setMaxAge(maxAge);