fluffynuts commented on code in PR #369:
URL: https://github.com/apache/logging-log4net/pull/369#discussion_r4647724170


##########
src/log4net/Appender/RollingFileAppender.cs:
##########
@@ -606,6 +606,20 @@ protected virtual void AdjustFileBeforeAppend()
     }
   }
 
+  /// <summary>
+  /// Retries a failed open with the base file name, as <see cref="OpenFile"/> 
adds the suffix itself.
+  /// </summary>
+  protected override void PrepareWriter()
+  {
+    if (_baseFileName is null)

Review Comment:
   minor: var off in case of a separate thread nulling out _baseFileName?



##########
src/log4net.Tests/Appender/Internal/CountingInterProcessLock.cs:
##########
@@ -0,0 +1,56 @@
+#region Apache License
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System.IO;
+using System.Text;
+
+using log4net.Appender;
+
+namespace log4net.Tests.Appender.Internal;
+
+/// <summary>Counts the calls to <see 
cref="FileAppender.InterProcessLock.AcquireLock"/>, and the files opened and 
closed.</summary>
+internal sealed class CountingInterProcessLock : FileAppender.InterProcessLock
+{
+  internal int Acquired { get; set; }
+
+  internal int Opened { get; private set; }
+
+  internal int Closed { get; private set; }
+
+  /// <inheritdoc/>
+  public override Stream? AcquireLock()
+  {
+    Acquired++;
+    return base.AcquireLock();
+  }
+
+  /// <inheritdoc/>
+  public override void OpenFile(string filename, bool append, Encoding 
encoding)
+  {
+    Opened++;

Review Comment:
   same here about interlocked



##########
src/log4net.Tests/Appender/Internal/CountingInterProcessLock.cs:
##########
@@ -0,0 +1,56 @@
+#region Apache License
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System.IO;
+using System.Text;
+
+using log4net.Appender;
+
+namespace log4net.Tests.Appender.Internal;
+
+/// <summary>Counts the calls to <see 
cref="FileAppender.InterProcessLock.AcquireLock"/>, and the files opened and 
closed.</summary>
+internal sealed class CountingInterProcessLock : FileAppender.InterProcessLock
+{
+  internal int Acquired { get; set; }
+
+  internal int Opened { get; private set; }
+
+  internal int Closed { get; private set; }
+
+  /// <inheritdoc/>
+  public override Stream? AcquireLock()
+  {
+    Acquired++;

Review Comment:
   what's the concurrency expectation here? should this use InterLocked?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to