You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/03/05 14:20:28 UTC
[GitHub] [bookkeeper] aloyszhang edited a comment on issue #2280: #2279 fix
NPE when exec readjournal command
aloyszhang edited a comment on issue #2280: #2279 fix NPE when exec readjournal command
URL: https://github.com/apache/bookkeeper/pull/2280#issuecomment-595249788
Parameter `-dir` must be specified if bookie has more than one directories for `journalDirectories` while not needed when only one journal directory.
So when have multi directories for `journalDirectories` , there will be always `NullPointerException ` when run the command `shell readjournal`.
Key code are
```
if (getJournals(conf).size() > 1) {
if (cmd.dir.equals(DEFAULT)) {
System.err.println("ERROR: invalid or missing journal directory");
usage();
return false;
}
File journalDirectory = new File(cmd.dir);
for (Journal j : getJournals(conf)) {
if (j.getJournalDirectory().equals(journalDirectory)) {
journal = j;
break;
}
}
if (journal == null) {
System.err.println("ERROR: journal directory not found");
usage();
return false;
}
} else {
journal = getJournals(conf).get(0);
}
```
The problem cause by `cmd.dir.equals(DEFAULT)` , when `cmd.dir` is null, bookie throws NPE.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services