fix npe for getLength in class of EntryImpl #14568
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
In pulsar broker logs, npe errors were found:
00:46:15.817 [BookKeeperClientWorker-OrderedExecutor-45-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
java.lang.NullPointerException: null
at org.apache.bookkeeper.mledger.impl.EntryImpl.getLength(EntryImpl.java:133) ~[org.apache.pulsar-managed-ledger-2.8.1.2.jar:2.8.1.2]
at org.apache.bookkeeper.mledger.util.RangeCache.put(RangeCache.java:78) ~[org.apache.pulsar-managed-ledger-2.8.1.2.jar:2.8.1.2]
at org.apache.bookkeeper.mledger.impl.EntryCacheImpl.insert(EntryCacheImpl.java:114) ~[org.apache.pulsar-managed-ledger-2.8.1.2.jar:2.8.1.2]
at org.apache.bookkeeper.mledger.impl.OpAddEntry.safeRun(OpAddEntry.java:198) ~[org.apache.pulsar-managed-ledger-2.8.1.2.jar:2.8.1.2]
at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) [org.apache.bookkeeper-bookkeeper-common-4.14.2.1.jar:4.14.2.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.66.Final.jar:4.1.66.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
Modifications
Make a non-null judgment on data in the method getLength
Documentation
Check the box below or label this PR directly (if you have committer privilege).
Need to update docs?
doc-required
(If you need help on updating docs, create a doc issue)
no-need-doc
(Please explain why)
doc
(If this PR contains doc changes)