sebb        2003/12/19 17:47:23

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        HTTPSampler.java
  Log:
  Log some extra information when an error occurs
  
  Revision  Changes    Path
  1.76      +24 -3     
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- HTTPSampler.java  20 Dec 2003 00:04:55 -0000      1.75
  +++ HTTPSampler.java  20 Dec 2003 01:47:23 -0000      1.76
  @@ -845,6 +845,7 @@
       {
           byte[] readBuffer= JMeterContextService.getContext().getReadBuffer();
           BufferedInputStream in;
  +        boolean logError=false; // Should we log the error?
           try
           {
               if (conn.getContentEncoding() != null
  @@ -867,14 +868,24 @@
               }
               else
               {
  -                log.error("Getting error message from server: "+e.toString());
  +                log.error(e.toString());
  +                Throwable cause = e.getCause();
  +                if (cause != null){
  +                     log.error("Cause: "+cause);
  +                }
  +                logError=true;
               }
               in= new BufferedInputStream(conn.getErrorStream());
           }
           catch (Exception e)
           {
  -            log.error("Getting error message from server: "+e.toString());
  +            log.error(e.toString());
  +                     Throwable cause = e.getCause();
  +                     if (cause != null){
  +                             log.error("Cause: "+cause);
  +                     }
               in= new BufferedInputStream(conn.getErrorStream());
  +                     logError=true;
           }
           java.io.ByteArrayOutputStream w= new ByteArrayOutputStream();
           int x= 0;
  @@ -885,6 +896,16 @@
           in.close();
           w.flush();
           w.close();
  +        if (logError)
  +        {
  +             String s;
  +             if (w.size() > 1000){
  +                             s="\n"+w.toString().substring(0,1000)+"\n\t...";
  +             } else {
  +                             s="\n"+w.toString();
  +             }
  +             log.error(s);
  +        }
           return w.toByteArray();
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to