[ 
https://issues.apache.org/jira/browse/LOG4J2-2788?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Piotr Karwasz reassigned LOG4J2-2788:
-------------------------------------

    Assignee: Piotr Karwasz

> Replace ThreadContext.EmptyIterator with JDK variant
> ----------------------------------------------------
>
>                 Key: LOG4J2-2788
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2788
>             Project: Log4j 2
>          Issue Type: Story
>          Components: Core
>    Affects Versions: 2.13.0
>            Reporter: Marius Volkhart
>            Assignee: Piotr Karwasz
>            Priority: Minor
>
> {{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)

Reply via email to