ppkarwasz commented on code in PR #1961:
URL: https://github.com/apache/logging-log4j2/pull/1961#discussion_r1389991083
##########
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessageFactory.java:
##########
@@ -30,6 +30,7 @@
* @since 2.6
*/
@PerformanceSensitive("allocation")
+@SuppressWarnings("ThreadLocalUsage")
Review Comment:
Sorry I didn't add the meaning of all these warnings in comments (cf. [Error
Prone documentation](http://errorprone.info/bugpatterns))
[ThreadLocalUsage](http://errorprone.info/bugpattern/ThreadLocalUsage)
actually means: only use `static` thread locals.
I believe we should use instance thread locals for singleton's like this. We
only need to ensure that this is a singleton (except in tests). E.g. if a user
asks for the message factory
`org.apache.logging.log4j.message.ReusableMessageFactory`, we can do like
`ServiceLoader` in Java 9+: look for a static `#provider` method and only if
this is not found instantiate the class.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]