[ 
https://issues.apache.org/jira/browse/LOG4J2-1874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053086#comment-16053086
 ] 

ASF subversion and git services commented on LOG4J2-1874:
---------------------------------------------------------

Commit d92cc27d3cdc0a5d7e7f8c519abf592c547e015b in logging-log4j2's branch 
refs/heads/master from rpopma
[ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=d92cc27 ]

LOG4J2-1874 add writeBytes methods to ByteBufferDestination

Added methods ::writeBytes(ByteBuffer) and ::writeBytes(byte[], int, int) to 
ByteBufferDestination interface and use these methods in TextEncoderHelper 
where possible to prepare for future enhancements to reduce lock contention.
Closes GitHub pull request #71


> Add ByteBufferDestionation.write(ByteBuffer) and write(byte[], int, int) 
> methods and call them from TextEncoderHelper whenever possible
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1874
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1874
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.6
>            Reporter: Roman Leventov
>            Assignee: Remko Popma
>             Fix For: 2.9
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to