[ https://issues.apache.org/jira/browse/BOOKKEEPER-957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15590172#comment-15590172 ]
ASF GitHub Bot commented on BOOKKEEPER-957: ------------------------------------------- GitHub user reddycharan opened a pull request: https://github.com/apache/bookkeeper/pull/65 BOOKKEEPER-957: LedgerHandleAdv fixes - making addToLength call synchronized - adding op to pendingAddOps after doing sanity check You can merge this pull request into a Git repository by running: $ git pull https://github.com/reddycharan/bookkeeper ledgerhandleadvfix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/bookkeeper/pull/65.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #65 ---- commit 375e532d42d0117d99c662732fe3e1e8ab85d1e0 Author: Charan Reddy Guttapalem <cguttapa...@salesforce.com> Date: 2016-10-19T22:56:38Z BOOKKEEPER-957: LedgerHandleAdv fixes - making addToLength call synchronized - adding op to pendingAddOps after doing sanity check ---- > issues in LedgerHandleAdv > -------------------------- > > Key: BOOKKEEPER-957 > URL: https://issues.apache.org/jira/browse/BOOKKEEPER-957 > Project: Bookkeeper > Issue Type: Bug > Reporter: Charan Reddy Guttapalem > Assignee: Charan Reddy Guttapalem > > 1) In LedgerHandleAdv in doAsyncAddEntry method, addToLength(length) call is > not synchronized > In LedgerHandleAdv in doAsyncAddEntry method, call to addToLength(length) is > not synchronized. > addEntry method is supposed to be thread safe, so when addEntry method of > LedgerHandleAdv is called concurrently from multiple threads, addToLength > will be messed up because its call is not synchrnoized. > in LedgerHandle it is synchronized over 'this'. > 2) In LedgerHandleAdv, in asyncAddEntry it is incorrect to add 'op' to > 'pendingAddOps' before calling doAsyncAddEntry > In LedgerHandleAdv, in asyncAddEntry, it is incorrect to add 'op' to > 'pendingAddOps' before calling doAsyncAddEntry. > Consider the following example, > Lets say "asyncAddEntry(final long entryId, final byte[] data, final int > offset, final int length, final AddCallback cb, final Object ctx)" is called > with incorrect arguments, and following condition is failed "(offset < 0 || > length < 0 || (offset + length) > data.length)". Then as expected we would > get ArrayIndexOutOfBoundsException, but now if we try to call asyncAddEntry > with correct arguments for that entry, then it will fail with > "DuplicateEntryIdException", since the op is added already in the previous > call, which shouldn't have happened. -- This message was sent by Atlassian JIRA (v6.3.4#6332)