[
https://issues.apache.org/jira/browse/ZOOKEEPER-3006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16412662#comment-16412662
]
ASF GitHub Bot commented on ZOOKEEPER-3006:
-------------------------------------------
GitHub user edwardoliveira opened a pull request:
https://github.com/apache/zookeeper/pull/493
ZOOKEEPER-3006: Potential NPE in ZKDatabase#calculateTxnLogSizeLimit
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/eribeiro/zookeeper zk-3006-potential-npe
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/zookeeper/pull/493.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 #493
----
commit c0a9763c5a0fc63d2cad99ea9d219c08fd454d2e
Author: Edward Ribeiro <edward.ribeiro@...>
Date: 2018-03-24T15:35:27Z
ZOOKEEPER-3006: Potential NPE in ZKDatabase#calculateTxnLogSizeLimit
----
> 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)