vmassol     01/05/02 08:16:48

  Modified:    cactus/src/ant/org/apache/commons/cactus/ant
                        StartServerHelper.java StopServerHelper.java
  Log:
  applied patch from Arun Katkere in order to prevent the "connexion reset by peer" 
error message when the connection is broken without reading the requested URL.
  
  Revision  Changes    Path
  1.3       +11 -0     
jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StartServerHelper.java
  
  Index: StartServerHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StartServerHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StartServerHelper.java    2001/04/14 14:54:49     1.2
  +++ StartServerHelper.java    2001/05/02 15:16:41     1.3
  @@ -116,6 +116,7 @@
           try {
               HttpURLConnection connection = 
(HttpURLConnection)m_TestURL.openConnection();
               connection.connect();
  +            readFully(connection);
               connection.disconnect();
   
               // Server is already running. Make this task a no-op.
  @@ -145,6 +146,7 @@
               try {
                   HttpURLConnection connection = 
(HttpURLConnection)m_TestURL.openConnection();
                   connection.connect();
  +                readFully(connection);
                   connection.disconnect();
               } catch (IOException e) {
                   try {
  @@ -166,6 +168,15 @@
           }
   
           // We're done ... Ant will continue processing other tasks
  +    }
  +
  +    static void readFully(HttpURLConnection connection) throws IOException
  +    {
  +        // finish reading it to prevent (harmless) server-side exceptions
  +        BufferedInputStream is = new 
BufferedInputStream(connection.getInputStream());
  +        byte[] buffer = new byte[256];
  +        while((is.read(buffer)) > 0) {}
  +        is.close();
       }
   
       /**
  
  
  
  1.3       +2 -0      
jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StopServerHelper.java
  
  Index: StopServerHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StopServerHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StopServerHelper.java     2001/04/14 14:55:18     1.2
  +++ StopServerHelper.java     2001/05/02 15:16:43     1.3
  @@ -111,6 +111,7 @@
           try {
               HttpURLConnection connection = 
(HttpURLConnection)m_TestURL.openConnection();
               connection.connect();
  +            StartServerHelper.readFully(connection);
               connection.disconnect();
           } catch (IOException e) {
               // Server is not running. Make this task a no-op.
  @@ -134,6 +135,7 @@
               try {
                   HttpURLConnection connection = 
(HttpURLConnection)m_TestURL.openConnection();
                   connection.connect();
  +                StartServerHelper.readFully(connection);
                   connection.disconnect();
               } catch (IOException e) {
                   break;
  
  
  

Reply via email to