Remove properties cache and token-based matching #2849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
PropertiesUtil
class preemptively caches lookups for all known keys from enumerable property sources.On my Debian system a JVM has around 60 among environment variables and system properties, which causes
PropertiesUtil
to perform around 60 lookups for each of the 3 standard property sources. Most of these properties have nothing to do with Log4j.On the other hand all Log4j artifacts use no more than 100 configuration properties and the results of most of those calls are cache in static fields.
This PR removes the property value caches used by
PropertiesUtil
.The change should have no noticeable impact on the loading time of Log4j Core, while at the same time simplifies the system.
As remarkable side effect token-based matching of property names is no longer supported. This mean that, e.g. a system property like
log4j2.asyncLoggerRingBufferSize
can be written:AsyncLogger.RingBufferSize
(pre-2.10 legacy form),log4j2.asyncLoggerRingBufferSize
(2.10 canonical form).No other forms (e.g.
log4j.async.logger.ringBuffer.size
) are accepted.Note: We never documented that we support token-based matching. See current Configuration Properties documentation.