You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2021/12/30 13:33:16 UTC
[logging-log4j2] branch master updated (61d63ee -> 3753476)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.
from 61d63ee Fix indentation and formatting.
new eb67ec6 Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to provide source compatibility.
new 3753476 Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to provide source compatibility.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java | 11 ++++++-----
log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java | 12 ++++++++++++
src/changes/changes.xml | 3 +++
3 files changed, 21 insertions(+), 5 deletions(-)
[logging-log4j2] 02/02: Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to provide source compatibility.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 37534762054072344398f3cf4ff3b65f0b492f95
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 30 08:33:13 2021 -0500
Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to
provide source compatibility.
---
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0330fd0..19e9a1f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -176,6 +176,9 @@
<action dev="ggregory" type="fix">
Log4j 1.2 bridge class ConsoleAppender should extend WriterAppender and provide better compatibility with custom appenders.
</action>
+ <action dev="ggregory" type="fix">
+ Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to provide source compatibility.
+ </action>
</release>
<release version="2.17.1" date="2021-MM-DD" description="GA Release 2.17.1">
<action issue="LOG4J2-3292" dev="ckozak" type="fix">
[logging-log4j2] 01/02: Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to provide source compatibility.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit eb67ec6f0188d086367bd3e1aecca975081c0479
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 30 08:20:28 2021 -0500
Log4j 1.2 bridge method NDC.inherit(Stack) should not use generics to
provide source compatibility.
---
log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java | 11 ++++++-----
log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java | 12 ++++++++++++
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java b/log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java
index a4e23dc..72efe04 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/NDC.java
@@ -19,7 +19,7 @@ package org.apache.log4j;
import java.util.Stack;
/**
- *
+ * <em>This class does not use generics to provide better source compatibility.</em>
*/
public final class NDC {
@@ -52,7 +52,7 @@ public final class NDC {
* The child thread uses the {@link #inherit inherit} method to
* inherit the parent's diagnostic context.
* </p>
- * @return Stack A clone of the current thread's diagnostic context.
+ * @return Stack A clone of the current thread's diagnostic context, Stack of Strings.
*/
@SuppressWarnings("rawtypes")
public static Stack cloneStack() {
@@ -65,7 +65,7 @@ public final class NDC {
/**
- * Inherit the diagnostic context of another thread.
+ * Inherit the diagnostic context of another thread, a Stack of Strings.
* <p>
* The parent thread can obtain a reference to its diagnostic
* context using the {@link #cloneStack} method. It should
@@ -83,9 +83,10 @@ public final class NDC {
* there is no client-transparent way of inheriting diagnostic
* contexts. Do you know any solution to this problem?
* </p>
- * @param stack The diagnostic context of the parent thread.
+ * @param stack The diagnostic context of the parent thread, a Stack of Strings.
*/
- public static void inherit(final Stack<String> stack) {
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static void inherit(final Stack stack) {
org.apache.logging.log4j.ThreadContext.setStack(stack);
}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
index c8baf0f..41ba015 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.log4j;
+import java.util.Stack;
+
import org.apache.logging.log4j.util.Strings;
import org.junit.Assert;
import org.junit.Test;
@@ -33,4 +35,14 @@ public class NDCTest {
NDC.clear();
Assert.assertEquals(Strings.EMPTY, NDC.peek());
}
+
+ @SuppressWarnings({"rawtypes"})
+ @Test
+ public void testCompileCloneToInherit() {
+ NDC.inherit(NDC.cloneStack());
+ final Stack stackRaw = NDC.cloneStack();
+ NDC.inherit(stackRaw);
+ final Stack<?> stackAny = NDC.cloneStack();
+ NDC.inherit(stackAny);
+ }
}