[
https://issues.apache.org/jira/browse/ZOOKEEPER-3006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16412874#comment-16412874
]
ASF GitHub Bot commented on ZOOKEEPER-3006:
-------------------------------------------
Github user eribeiro commented on the issue:
https://github.com/apache/zookeeper/pull/493
@anmoldar thanks for the feedback! Gonna update the description and add a
test case asap. Btw, I am not the one who found this potential npe, but I am
glad to help. :) Last but not least, I opened the PR for master, but should we
address this issue on previous branches too?
@LJ1043041006 yup, I don't think the failed tests are related to this patch
at all. Gonna take a closer look really soon. ZK has some flaky tests, but
looks like there was an exception that prevented any test from running.
> Potential NPE in ZKDatabase#calculateTxnLogSizeLimit
> ----------------------------------------------------
>
> Key: ZOOKEEPER-3006
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3006
> Project: ZooKeeper
> Issue Type: Bug
> Affects Versions: 3.6.0
> Reporter: lujie
> Priority: Major
>
> I have found a potential NPE in ZKDatabase#calculateTxnLogSizeLimit:
>
> {code:java}
> //ZKDatabase
> public long calculateTxnLogSizeLimit() {
> long snapSize = 0;
> try {
> snapSize = snapLog.findMostRecentSnapshot().length();
> } catch (IOException e) {
> LOG.error("Unable to get size of most recent snapshot");
> }
> return (long) (snapSize * snapshotSizeFactor);
> }
> {code}
> in FileTxnSnapLog#findMostRecentSnapshot(), it will return the result of
> FileSnap#findMostRecentSnapshot:
> {code:java}
> // called by FileTxnSnapLog#findMostRecentSnapshot()
> public File findMostRecentSnapshot() throws IOException {
> List<File> files = findNValidSnapshots(1);
> if (files.size() == 0) {
> return null;
> }
> return files.get(0);
> }
> {code}
> So it will return null when the files sizes is 0, but
> ZKDatabase#calculateTxnLogSizeLimit has no null checker
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)