[ 
https://issues.apache.org/jira/browse/LOG4J2-2899?focusedWorklogId=460744&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460744
 ]

ASF GitHub Bot logged work on LOG4J2-2899:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Jul/20 17:46
            Start Date: 18/Jul/20 17:46
    Worklog Time Spent: 10m 
      Work Description: carterkozak commented on pull request #390:
URL: https://github.com/apache/logging-log4j2/pull/390#issuecomment-660516966


   @rgoers, I'd appreciate your feedback on this change when you have time. I'm 
primarily interested in whether or not you think it's reasonable to replace 
`Thread.getAllStackTraces()` with the simpler current-thread check, 
applications with several thousand threads will suffer creating large arrays, 
and loading many stack traces unnecessarily.
   
   If the cross-thread check is a requirement, I think the following could work:
   1: First check the current thread at construction time, if it matches the 
event thread name there's no more work to do
   2: When an identifier or priority is first requested, we can attempt to use 
ThreadMXBean.getAllThreadIds and use the result to call getThreadInfo with 
maxDepth zero to avoid forcing a safepoint and reduce the heap requirement of 
the result.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 460744)
    Time Spent: 20m  (was: 10m)

> LogEventWrapper.getThread only works on the first invocation
> ------------------------------------------------------------
>
>                 Key: LOG4J2-2899
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2899
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: log4j 1.2 emulation
>    Affects Versions: 2.13.3
>            Reporter: Carter Kozak
>            Assignee: Carter Kozak
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> LogEventWrapper.getThread attempts to memoize the thread value but returns 
> null if the thread field is already set where it should return the field 
> value.
>  
> Additionally the thread is discovered using Thread.getAllStackTraces which is 
> an expensive operation. In most cases it should be sufficient to check only 
> the current thread, if the getThread method is called from another thread 
> there's no guarantee that the original thread still uses the same name, or 
> that it still exists.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to