hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1378925 - in /httpcomponents/httpclient/branches/4.2.x: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
Date Thu, 30 Aug 2012 13:26:20 GMT
Author: olegk
Date: Thu Aug 30 13:26:20 2012
New Revision: 1378925

URL: http://svn.apache.org/viewvc?rev=1378925&view=rev
Log:
HTTPCLIENT-1227: Date parsing in DateUtils made more efficient
Contributed by Patrick Linskey <pcl at apache.org>

Modified:
    httpcomponents/httpclient/branches/4.2.x/RELEASE_NOTES.txt
    httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java

Modified: httpcomponents/httpclient/branches/4.2.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.2.x/RELEASE_NOTES.txt?rev=1378925&r1=1378924&r2=1378925&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.2.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/branches/4.2.x/RELEASE_NOTES.txt Thu Aug 30 13:26:20 2012
@@ -1,11 +1,15 @@
 Changes since 4.2.1
 
+* [HTTPCLIENT-1227] Date parsing in DateUtils made more efficient.
+  Contributed by Patrick Linskey <pcl at apache.org>
+
 * [HTTPCLIENT-1224] (regression) NTLM auth not retried after a redirect over a non-persistent

   connection.
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 
 * [HTTPCLIENT-1223] Cache could be more aggressive on cache invalidations
   from Content-Location. Contributed by Jon Moore <jonm at apache.org>.
+  Contributed by Jon Moore <jonm at apache.org>
 
 * [HTTPCLIENT-1217] AutoRetryHttpClient does not release connection used by the previous
response 
   when request is retried

Modified: httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java?rev=1378925&r1=1378924&r2=1378925&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
(original)
+++ httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java
Thu Aug 30 13:26:20 2012
@@ -29,7 +29,7 @@ package org.apache.http.impl.cookie;
 
 import java.lang.ref.SoftReference;
 import java.text.DateFormat;
-import java.text.ParseException;
+import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -68,8 +68,8 @@ public final class DateUtils {
     public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
 
     private static final String[] DEFAULT_PATTERNS = new String[] {
-        PATTERN_RFC1036,
         PATTERN_RFC1123,
+        PATTERN_RFC1036,
         PATTERN_ASCTIME
     };
 
@@ -156,12 +156,10 @@ public final class DateUtils {
         for (String dateFormat : dateFormats) {
             SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormat);
             dateParser.set2DigitYearStart(startDate);
-
-            try {
-                return dateParser.parse(dateValue);
-            } catch (ParseException pe) {
-                // ignore this exception, we will try the next format
-            }
+            ParsePosition pos = new ParsePosition(0);
+            Date result = dateParser.parse(dateValue, pos);
+            if (pos.getIndex() != 0)
+                return result;
         }
 
         // we were unable to parse the date



Mime
View raw message