I have a very simple method that scans a directory structure to perform a check. The scanning looking like this:
File file = new File(initpath);
for(File hex : file.listFiles(new HexagonNameFilter())) {
for(File wall : hex.listFiles()) {
for(File shelf : wall.listFiles()) {
for(File book : shelf.listFiles()) {
// Perform some actual work
}
}
}
}
The method is called lots of times during the execution of the program.
Inconsistently (meaning, at some unpredictable point in the scanning process), I get a java.lang.NullPointerException with the stack trace pointing at one of the for statements (which one it is is also inconsistent). This is not enlightening. I was thinking of passing FilenameFilters to the three listFiles() calls, but can't see how that would help the issue.