Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/log4net.Tests/Appender/RollingFileAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,17 @@ public void TestInitializeRollBackups4()
VerifyInitializeRollBackups(8, iMaxRollBackups);
}

/// <summary>
/// Ensures that no problems result from creating and then closing the appender
/// when it has not also been initialized with ActivateOptions().
/// </summary>
[Test]
public void TestCreateCloseNoActivateOptions()
{
var appender = new RollingFileAppender();
appender.Close();
}

/// <summary>
///
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/log4net.Tests/log4net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NExpect" Version="1.0.273" />
<PackageReference Include="Quackers.TestLogger" Version="1.0.24" />
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Appender/FileAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private LockStateException(SerializationInfo info, StreamingContext context) : b
}

private Stream m_realStream = null;
private LockingModelBase m_lockingModel = null;
private readonly LockingModelBase m_lockingModel;
private int m_lockLevel = 0;

public LockingStream(LockingModelBase locking)
Expand Down Expand Up @@ -1306,7 +1306,7 @@ protected override void Reset()
protected override void OnClose()
{
base.OnClose();
m_lockingModel.OnClose();
m_lockingModel?.OnClose();
}

/// <summary>
Expand Down