hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r603319 - /jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
Date Tue, 11 Dec 2007 18:13:01 GMT
Author: olegk
Date: Tue Dec 11 10:13:00 2007
New Revision: 603319

URL: http://svn.apache.org/viewvc?rev=603319&view=rev
Log:
Ain't generics fun?

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java?rev=603319&r1=603318&r2=603319&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
Tue Dec 11 10:13:00 2007
@@ -32,6 +32,7 @@
 package org.apache.http.impl.cookie;
 
 import java.lang.ref.SoftReference;
+import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -213,10 +214,12 @@
      */
     final static class DateFormatHolder {
 
-        private static final ThreadLocal THREADLOCAL_FORMATS = new ThreadLocal() {
+        private static final ThreadLocal<SoftReference<Map<String, DateFormat>>>

+            THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, DateFormat>>>()
{
 
-            protected Object initialValue() {
-                return new SoftReference(new HashMap());
+            protected SoftReference<Map<String, DateFormat>> initialValue() {
+                return new SoftReference<Map<String, DateFormat>>(
+                        new HashMap<String, DateFormat>());
             }
             
         };
@@ -234,11 +237,11 @@
          *         different pattern.
          */
         public static SimpleDateFormat formatFor(String pattern) {
-            SoftReference ref = (SoftReference) THREADLOCAL_FORMATS.get();
-            Map formats = (Map) ref.get();
+            SoftReference<Map<String, DateFormat>> ref = THREADLOCAL_FORMATS.get();
+            Map<String, DateFormat> formats = ref.get();
             if (formats == null) {
-                formats = new HashMap();
-                THREADLOCAL_FORMATS.set(new SoftReference(formats));    
+                formats = new HashMap<String, DateFormat>();
+                THREADLOCAL_FORMATS.set(new SoftReference<Map<String, DateFormat>>(formats));
   
             }
 
             SimpleDateFormat format = (SimpleDateFormat) formats.get(pattern);



Mime
View raw message