You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Wenjun Ruan (Jira)" <ji...@apache.org> on 2021/05/16 16:00:00 UTC

[jira] [Created] (ZOOKEEPER-4294) FileSnap#findNValidSnapshots should not declare IOException

Wenjun Ruan created ZOOKEEPER-4294:
--------------------------------------

             Summary: FileSnap#findNValidSnapshots should not declare IOException
                 Key: ZOOKEEPER-4294
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4294
             Project: ZooKeeper
          Issue Type: Bug
          Components: server
            Reporter: Wenjun Ruan


The IOException has already been caught
{code:java}
protected List<File> findNValidSnapshots(int n) throws IOException {
    List<File> files = Util.sortDataDir(snapDir.listFiles(), SNAPSHOT_FILE_PREFIX, false);
    int count = 0;
    List<File> list = new ArrayList<File>();
    for (File f : files) {
        // we should catch the exceptions
        // from the valid snapshot and continue
        // until we find a valid one
        try {
            if (SnapStream.isValidSnapshot(f)) {
                list.add(f);
                count++;
                if (count == n) {
                    break;
                }
            }
        } catch (IOException e) {
            LOG.warn("invalid snapshot {}", f, e);
        }
    }
    return list;
}
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)