Author: vsiveton
Date: Thu Nov 18 12:56:17 2010
New Revision: 1036439

URL: http://svn.apache.org/viewvc?rev=1036439&view=rev
Log:
MPIR-199: ProjectInfoReportUtils.java : Avoid using blocking call [ 
url.openStream() ] while opening stream from an URL

o added Prashant Bhate's proposal

Modified:
    
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java

Modified: 
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java?rev=1036439&r1=1036438&r2=1036439&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
 (original)
+++ 
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
 Thu Nov 18 12:56:17 2010
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -52,6 +53,9 @@ public class ProjectInfoReportUtils
 {
     private static final UrlValidator URL_VALIDATOR = new UrlValidator( new 
String[] { "http", "https" } );
 
+    /** The timeout when getting the url input stream */
+    private static final int TIMEOUT = 1000 * 5;
+
     /**
      * Get the input stream using ISO-8859-1 as charset from an URL.
      *
@@ -130,7 +134,10 @@ public class ProjectInfoReportUtils
         InputStream in = null;
         try
         {
-            in = url.openStream();
+            URLConnection conn = url.openConnection();
+            conn.setConnectTimeout( TIMEOUT );
+            conn.setReadTimeout( TIMEOUT );
+            in = conn.getInputStream();
 
             if ( encoding == null )
             {


Reply via email to