logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1169783 - /logging/log4net/trunk/src/Layout/XMLLayoutBase.cs
Date Mon, 12 Sep 2011 14:57:12 GMT
Author: bodewig
Date: Mon Sep 12 14:57:12 2011
New Revision: 1169783

URL: http://svn.apache.org/viewvc?rev=1169783&view=rev
Log:
Fix race-condition in XmlLayoutBase. LOG4NET-76

Modified:
    logging/log4net/trunk/src/Layout/XMLLayoutBase.cs

Modified: logging/log4net/trunk/src/Layout/XMLLayoutBase.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Layout/XMLLayoutBase.cs?rev=1169783&r1=1169782&r2=1169783&view=diff
==============================================================================
--- logging/log4net/trunk/src/Layout/XMLLayoutBase.cs (original)
+++ logging/log4net/trunk/src/Layout/XMLLayoutBase.cs Mon Sep 12 14:57:12 2011
@@ -197,10 +197,7 @@ namespace log4net.Layout
 				throw new ArgumentNullException("loggingEvent");
 			}
 
-			// Attach the protected writer to the TextWriter passed in
-			m_protectCloseTextWriter.Attach(writer);
-
-			XmlTextWriter xmlWriter = new XmlTextWriter(m_protectCloseTextWriter);
+			XmlTextWriter xmlWriter = new XmlTextWriter(new ProtectCloseTextWriter(writer));
 			xmlWriter.Formatting = Formatting.None;
 			xmlWriter.Namespaces = false;
 
@@ -212,9 +209,6 @@ namespace log4net.Layout
 			// Close on xmlWriter will ensure xml is flushed
 			// the protected writer will ignore the actual close
 			xmlWriter.Close();
-
-			// detach from the writer
-			m_protectCloseTextWriter.Attach(null);
 		}
 
 		#endregion Override implementation of LayoutSkeleton
@@ -245,11 +239,6 @@ namespace log4net.Layout
 		private bool m_locationInfo = false;
 
 		/// <summary>
-		/// Writer adapter that ignores Close
-		/// </summary>
-		private readonly ProtectCloseTextWriter m_protectCloseTextWriter = new ProtectCloseTextWriter(null);
-
-		/// <summary>
 		/// The string to replace invalid chars with
 		/// </summary>
 		private string m_invalidCharReplacement="?";



Mime
View raw message