balld 01/08/06 13:02:45 Modified: src/org/apache/cocoon/environment/http HttpRequest.java Log: fixed a bug in the getCookieMap code and cleaned up the wrapping procedure Revision Changes Path 1.6 +20 -16 xml-cocoon2/src/org/apache/cocoon/environment/http/HttpRequest.java Index: HttpRequest.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/http/HttpRequest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HttpRequest.java 2001/07/20 09:04:23 1.5 +++ HttpRequest.java 2001/08/06 20:02:45 1.6 @@ -28,7 +28,7 @@ * to provide request information for HTTP servlets. * * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a> - * @version CVS $Id: HttpRequest.java,v 1.5 2001/07/20 09:04:23 cziegeler Exp $ + * @version CVS $Id: HttpRequest.java,v 1.6 2001/08/06 20:02:45 balld Exp $ */ public class HttpRequest implements Request { @@ -62,27 +62,31 @@ private Map wrappedCookieMap = null; public Cookie[] getCookies() { - if (this.wrappedCookies == null) { - this.wrappedCookieMap = new HashMap(); - javax.servlet.http.Cookie[] cookies = this.req.getCookies(); - if (cookies != null) { - this.wrappedCookies = new Cookie[cookies.length]; - for(int i=0; i<cookies.length;i++) { - HttpCookie cookie = new HttpCookie(cookies[i]); - this.wrappedCookies[i] = cookie; - this.wrappedCookieMap.put(cookie.getName(),cookie); - } - } + if (this.wrappedCookieMap == null) { + wrapCookies(); } return this.wrappedCookies; } public Map getCookieMap() { - if (this.wrappedCookieMap != null) { - return Collections.unmodifiableMap(this.wrappedCookieMap); - } else { - return Collections.unmodifiableMap(new HashMap()); + if (this.wrappedCookieMap == null) { + wrapCookies(); + } + return this.wrappedCookieMap; + } + + private synchronized void wrapCookies() { + this.wrappedCookieMap = new HashMap(); + javax.servlet.http.Cookie[] cookies = this.req.getCookies(); + if (cookies != null) { + this.wrappedCookies = new Cookie[cookies.length]; + for(int i=0; i<cookies.length;i++) { + HttpCookie cookie = new HttpCookie(cookies[i]); + this.wrappedCookies[i] = cookie; + this.wrappedCookieMap.put(cookie.getName(),cookie); + } } + this.wrappedCookieMap = Collections.unmodifiableMap(this.wrappedCookieMap); } public long getDateHeader(String name) { ---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]