-
-
Notifications
You must be signed in to change notification settings - Fork 340
#246 fix InvalidCastException in ThreadContextStack.InternalStack.set #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FreeAndNil
merged 1 commit into
master
from
Feature/#244-fix-InvalidCastException-in-ThreadContextStack.InternalStack.set
May 22, 2025
+119
−6
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
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.