Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve implementations of LogEvent.toImmutable() and ReusableMessage.memento() #3171

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

ppkarwasz
Copy link
Contributor

The implementations of LogEvent.toImmutable() either use serialization or one of the Log4jLogEvent.Builder constructors and custom per class code.

This PR:

  • Redirects all implementation of LogEvent.toImmutable to the Builder(LogEvent) constructor (except Log4jLogEvent.toImmutable())
  • Improve the constructor to create really immutable and thread-safe instances.
  • Removes the usage of ThrowableProxy for purposes not related to serialization.
  • Fixes some implementations of ReusableMessage.memento().
  • Uses ReusableMessage.memento() instead of ImmutableMessage where applicable.

The implementations of `LogEvent.toImmutable()` either use serialization or one of the `Log4jLogEvent.Builder` constructors and custom per class code.

This PR:

- Redirects all implementation of `LogEvent.toImmutable` to the `Builder(LogEvent)` constructor (except `Log4jLogEvent.toImmutable()`)
- Improve the constructor to create really immutable and thread-safe instances.
- Removes the usage of `ThrowableProxy` for purposes not related to serialization.
- Fixes some implementations of `ReusableMessage.memento()`.
- Uses `ReusableMessage.memento()` instead of `ImmutableMessage` where
  applicable.
Comment on lines -358 to -363
private void initTranslatorThreadValues(final RingBufferLogEventTranslator translator) {
// constant check should be optimized out when using default (CACHED)
if (THREAD_NAME_CACHING_STRATEGY == ThreadNameCachingStrategy.UNCACHED) {
translator.updateThreadValues();
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instances of RingBufferLogEventTranslator are always used on the same thread that created them.

@ppkarwasz ppkarwasz self-assigned this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant