Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.6
-
None
-
None
Description
Existing ByteBufferDestination API: getByteBuffer() and drain() is designed so that synchronization couldn't be avoided. This doesn't allow to implement LOG4J2-928.
Github PR: https://github.com/apache/logging-log4j2/pull/71
Added methods: write(ByteBuffer data) and write(byte[] data, int offset, int length) are designed so that they should care about synchronization themselves, internally, if needed. They should also synchronize with possible concurrent users of the synchronized getByteBuffer() + drain() API. Nevertheless, it allows for ByteBufferDestination implementations to implement write() methods without lock-free.
TextEncoderHelper (hence StringBuilderEncoder, which delegates it's logic to TextEncoderHelper) is changed so that it calls ByteBufferDestination.write() whenever possible. There is an expectation that most of encoded events fit the thread-local buffers, and write() could be called instead of writing to destination.getByteBuffer() with synchronization.
The PR also includes a sanity improvement: uses ByteBuffer.arrayOffset() at some places.
Attachments
Issue Links
- blocks
-
LOG4J2-928 Lock-free synchronous sub-microsecond appender
-
- Open
-
- links to