zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-3006) Potential NPE in ZKDatabase#calculateTxnLogSizeLimit
Date Mon, 26 Mar 2018 08:26:00 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-3006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16413558#comment-16413558
] 

ASF GitHub Bot commented on ZOOKEEPER-3006:
-------------------------------------------

Github user LJ1043041006 commented on the issue:

    https://github.com/apache/zookeeper/pull/493
  
    Hi guys, **one more thing**
    I have developed a very simple tool to find Potential NPE in Zookeeper(based on  [WALA](https://github.com/wala/WALA)),
I list the result in ZK-3007~3010
    , so anyone can help me confirm them and  improve this tool (hopefully it can be open
source  ) 


> 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
>            Assignee: Edward Ribeiro
>            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)

Mime
View raw message