nicko       2004/09/13 00:00:34

  Modified:    src/Util CountingQuietTextWriter.cs
  Log:
  Added check for null or zero length string
  
  Revision  Changes    Path
  1.3       +12 -9     logging-log4net/src/Util/CountingQuietTextWriter.cs
  
  Index: CountingQuietTextWriter.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Util/CountingQuietTextWriter.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CountingQuietTextWriter.cs        16 Feb 2004 02:10:54 -0000      1.2
  +++ CountingQuietTextWriter.cs        13 Sep 2004 07:00:34 -0000      1.3
  @@ -54,17 +54,20 @@
                /// <param name="str">The string data to write to the 
output.</param>
                override public void Write(string str) 
                {
  -                     try 
  +                     if (str != null && str.Length > 0)
                        {
  -                             base.Write(str);
  +                             try 
  +                             {
  +                                     base.Write(str);
   
  -                             // get the number of bytes needed to represent 
the 
  -                             // string using the supplied encoding.
  -                             m_countBytes += this.Encoding.GetByteCount(str);
  -                     }
  -                     catch(Exception e) 
  -                     {
  -                             this.ErrorHandler.Error("Failed to write [" + 
str + "].", e, ErrorCode.WriteFailure);
  +                                     // get the number of bytes needed to 
represent the 
  +                                     // string using the supplied encoding.
  +                                     m_countBytes += 
this.Encoding.GetByteCount(str);
  +                             }
  +                             catch(Exception e) 
  +                             {
  +                                     this.ErrorHandler.Error("Failed to 
write [" + str + "].", e, ErrorCode.WriteFailure);
  +                             }
                        }
                }
   
  
  
  

Reply via email to