harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r608499 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
Date Thu, 03 Jan 2008 14:27:05 GMT
Author: tellison
Date: Thu Jan  3 06:27:04 2008
New Revision: 608499

URL: http://svn.apache.org/viewvc?rev=608499&view=rev
Log:
Fix imports and warning of using deprecated method.
Ensure default value returned if date field not parsable.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?rev=608499&r1=608498&r2=608499&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
Thu Jan  3 06:27:04 2008
@@ -23,6 +23,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Collections;
+import java.util.Date;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -31,7 +32,6 @@
 import org.apache.harmony.luni.internal.net.www.MimeTable;
 import org.apache.harmony.luni.util.Msg;
 import org.apache.harmony.luni.util.PriviAction;
-import org.apache.harmony.luni.util.Util;
 
 /**
  * The URLConnection class is responsible for establishing a connection to an
@@ -505,18 +505,23 @@
      * @param field
      *            the field in question
      * @param defaultValue
-     *            the default value if no field is found
+     *            the default value if no field is found or the value is invalid
      * @return milliseconds since epoch
      * 
      * @see #ifModifiedSince
      * @see #setIfModifiedSince
      */
+    @SuppressWarnings("deprecation")
     public long getHeaderFieldDate(String field, long defaultValue) {
         String date = getHeaderField(field);
         if (date == null) {
             return defaultValue;
         }
-        return java.util.Date.parse(date);
+        try {
+            return Date.parse(date);
+        } catch (Exception e) {
+            return defaultValue;
+        }
     }
 
     /**



Mime
View raw message