Fix read empty ledger exception using bookkeeper admin
authorHang Chen <chenhang@apache.org>
Mon, 25 Apr 2022 22:28:04 +0000 (06:28 +0800)
committerGitHub <noreply@github.com>
Mon, 25 Apr 2022 22:28:04 +0000 (15:28 -0700)
commit083e2e94d18edcd85a1d25deaf77ecad0e3de61d
tree1ea89b0d450df4fcbfedbe6ab8b25f820ababbea
parent49bb6369fced44e60bd86dbadec53eec4d173e74
Fix read empty ledger exception using bookkeeper admin

### Motivation
Fix #3222

The root cause is that BookKeeperAdmin use `asyncReadEntriesInternal` to read entries. However, the `asyncReadEntriesInternal` doesn't check the lastAddConfirm, which will lead to the exception list in issue 3222

### Changes

Add lastAddConfirm check before call `asyncReadEntriesInternal`

Reviewers: Yong Zhang <zhangyong1025.zy@gmail.com>, Andrey Yegorov <None>

This closes #3240 from hangc0276/chenhang/fix_BKBookieHandleNotAvailableException_for_empty_ledger
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java