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
41 changes: 41 additions & 0 deletions src/changelog/3.1.1/.release-notes.adoc.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
////
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.
////

////
██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████ ██
██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██ ██
██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████ ██

IF THIS FILE DOESN'T HAVE A `.ftl` SUFFIX, IT IS AUTO-GENERATED, DO NOT EDIT IT!

Version-specific release notes (`7.8.0.adoc`, etc.) are generated from `src/changelog/*/.release-notes.adoc.ftl`.
Auto-generation happens during `generate-sources` phase of Maven.
Hence, you must always

1. Find and edit the associated `.release-notes.adoc.ftl`
2. Run `./mvnw generate-sources`
3. Commit both `.release-notes.adoc.ftl` and the generated `7.8.0.adoc`
////

[#release-notes-${release.version?replace("[^a-zA-Z0-9]", "-", "r")}]
== ${release.version}

<#if release.date?has_content>Release date:: ${release.date}</#if>

<#include "../.changelog.adoc.ftl">
6 changes: 6 additions & 0 deletions src/changelog/3.1.1/.release.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<release xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
date="2025-07-12"
version="3.1.1"/>
12 changes: 12 additions & 0 deletions src/changelog/3.1.1/245-ndc-inherit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="245" link="https://github.com/apache/logging-log4net/issues/245"/>
<issue id="246" link="https://github.com/apache/logging-log4net/pull/246"/>
<description format="asciidoc">
Fix InvalidCastException in NDC.Inherit(System.Collections.Stack)
(reported by @jberg7, implemented by @freeandnil in https://github.com/apache/logging-log4net/pull/246[#246])
</description>
</entry>
58 changes: 58 additions & 0 deletions src/log4net.Tests/NdcTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#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;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using log4net.Config;
using log4net.Core;
using log4net.Layout;
using log4net.Layout.Pattern;
using log4net.Repository;
using log4net.Tests.Appender;
using log4net.Util;
using NUnit.Framework;

namespace log4net.Tests;

/// <summary>
/// Used for internal unit testing the <see cref="NDC"/> class.
/// </summary>
[TestFixture]
public class NdcTest
{
/// <summary>
/// Test regression (https://github.com/apache/logging-log4net/issues/245)
/// </summary>
[Test]
public void InheritTest()
{
NDC.Push("first");
NDC.Push("last");
System.Collections.Stack context = NDC.CloneStack();
NDC.Clear();
NDC.Inherit(context);
Assert.That(NDC.Pop(), Is.EqualTo("last"));
Assert.That(NDC.Pop(), Is.EqualTo("first"));
}
}
4 changes: 0 additions & 4 deletions src/log4net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".doc", ".doc", "{33D80AD3-8048-4220-8BB0-38E3BDE5FCF4}"
ProjectSection(SolutionItems) = preProject
..\doc\BUILDING.md = ..\doc\BUILDING.md
site\xdoc\release\config-examples.xml = site\xdoc\release\config-examples.xml
site\xdoc\download_log4net.xml = site\xdoc\download_log4net.xml
..\doc\MailTemplate.Announce.txt = ..\doc\MailTemplate.Announce.txt
..\doc\MailTemplate.Result.txt = ..\doc\MailTemplate.Result.txt
..\doc\MailTemplate.txt = ..\doc\MailTemplate.txt
site\xdoc\release\release-notes.xml = site\xdoc\release\release-notes.xml
site\xdoc\release\release-review-instructions.xml = site\xdoc\release\release-review-instructions.xml
..\doc\RELEASING.md = ..\doc\RELEASING.md
EndProjectSection
EndProject
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Util/ThreadContextStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ internal Stack InternalStack
set
{
_stack.Clear();
var frames = (StackFrame[])value.ToArray();
object[] frames = value.ToArray();
for (int i = frames.Length - 1; i >= 0; i--)
{
_stack.Push(frames[i]);
_stack.Push(frames[i].EnsureIs<StackFrame>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: I'd suggest rather using pettern-matching instead of throwing if something in that array is wrong, eg

if (frames[i] is StackFrame s)
{
  _stack.Push(s)
}

This would stop a throw on invalid data set, but leave the collection empty, which may not be better - this may just be a stylistic choice on my part.

}
}
}
Expand Down