You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2022/05/02 21:10:00 UTC
[jira] [Updated] (LOG4J2-2788) Replace ThreadContext.EmptyIterator with JDK variant
[ https://issues.apache.org/jira/browse/LOG4J2-2788?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Volkan Yazici updated LOG4J2-2788:
----------------------------------
Fix Version/s: 2.18.0
(was: 2.17.3)
> Replace ThreadContext.EmptyIterator with JDK variant
> ----------------------------------------------------
>
> Key: LOG4J2-2788
> URL: https://issues.apache.org/jira/browse/LOG4J2-2788
> Project: Log4j 2
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.13.0
> Reporter: Marius Volkhart
> Assignee: Piotr Karwasz
> Priority: Minor
> Fix For: 2.18.0
>
>
> {{ThreadContext.java}} has a class, {{EmptyIterator}}, used in conjunction with the {{EmptyThreadContextStack}}. I'd like to propose replacing it with {{Collections.emptyIterator()}}.
> It was unclear from the comments and commit messages whether or not the {{EmptyIterator}} was used because {{Collections.emptyIterator()}} was not available, or because it was deemed unfit at the time. Log4J 2 requires Java 8 now, so using Java 7 classes is possible.
> Switching to the JDK variant results in a slight change in behavior. The {{EmptyIterator}} no-ops on a call to {{remove()}}. The JDK variant throws an {{IllegalStateException}}. This seems acceptable since all other mutator methods of the {{EmptyThreadContextStack}} throw an {{UnsupportedOperationException}}. While the exceptions aren't the same, it's clear that mutating isn't supported.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)