You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/02/15 23:12:48 UTC

svn commit: r153966 - in jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network: NetworkException.java ResourceRequestFactory.java

Author: burton
Date: Tue Feb 15 14:12:44 2005
New Revision: 153966

URL: http://svn.apache.org/viewcvs?view=rev&rev=153966
Log:
use a smarter cache policy for DNS requests

Modified:
    jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/NetworkException.java
    jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/ResourceRequestFactory.java

Modified: jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/NetworkException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/NetworkException.java?view=diff&r1=153965&r2=153966
==============================================================================
--- jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/NetworkException.java (original)
+++ jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/NetworkException.java Tue Feb 15 14:12:44 2005
@@ -19,6 +19,8 @@
 import java.io.IOException;
 import java.net.*;
 
+import org.apache.log4j.*;
+
 /**
  * 
  * @author <a href="mailto:burton@openprivacy.org">Kevin A. Burton</a>
@@ -26,6 +28,8 @@
  */
 public class NetworkException extends IOException {
 
+    private static Logger log = Logger.getLogger( NetworkException.class );
+
     private ResourceRequest request = null;
 
     public Exception e = null;
@@ -136,8 +140,17 @@
             int begin = "HTTP/1.1 ".length();
             int offset = "200".length();
             int end = begin + offset;
-            
-            responseCode = Integer.parseInt( status.substring( begin, end ) );
+
+            try {
+
+                responseCode = Integer.parseInt( status.substring( begin, end ) );
+                
+            } catch ( NumberFormatException e ) {
+
+                log.warn( "Unable to parse response code in header: " + status );
+                return -1;
+                
+            }
 
         } 
 

Modified: jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/ResourceRequestFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/ResourceRequestFactory.java?view=diff&r1=153965&r2=153966
==============================================================================
--- jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/ResourceRequestFactory.java (original)
+++ jakarta/commons/proper/feedparser/trunk/src/java/org/apache/commons/feedparser/network/ResourceRequestFactory.java Tue Feb 15 14:12:44 2005
@@ -27,7 +27,7 @@
  * URL.
  *
  * @author <a href="mailto:burton@openprivacy.org">Kevin A. Burton</a>
- * @version $Id: ResourceRequestFactory.java,v 1.2 2005/01/27 07:15:50 burton Exp $
+ * @version $Id$
  */
 public class ResourceRequestFactory {
 
@@ -48,8 +48,8 @@
      * 
      * A value of -1 indicates "cache forever".
      */
-    public static int NETWORKADDRESS_CACHE_TTL = 5 * 60 * 1000;
-
+    public static int NETWORKADDRESS_CACHE_TTL = 5 * 60;
+    
     /**
      * These properties specify the default connect and read timeout (resp.) for
      * the protocol handler used by java.net.URLConnection.
@@ -210,6 +210,9 @@
         System.setProperty( "sun.net.inetaddr.ttl",
                             Integer.toString( NETWORKADDRESS_CACHE_TTL ) );
 
+        System.setProperty( "networkaddress.cache.ttl",
+                            Integer.toString( NETWORKADDRESS_CACHE_TTL ) );
+
         System.setProperty( "sun.net.client.defaultReadTimeout",
                             Integer.toString( DEFAULT_READ_TIMEOUT ) );
 
@@ -218,7 +221,7 @@
 
         System.setProperty( "http.maxRedirects",
                             Integer.toString( DEFAULT_MAX_REDIRECTS ) );
-        
+
         if ( schemeMap == null ) {
             
             schemeMap = new HashMap();



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org