Source:
protected Index scanFolder(URI indexUri) throws IOException { File indexFile0 = new File(indexUri); File classesFolder = indexFile0.getParentFile().getParentFile(); try (LockedFile indexFile = new LockedFile(indexFile0)) { IndexMetaData newMeta = null; Index index = null; boolean indexFileExists = indexFile.exists(); if (indexFileExists) { switch (m_rebuildStrategy) { case IF_MODIFIED: newMeta = indexMetaData(classesFolder.toPath()); long oldModified = indexFile.lastModified(); if (newMeta.lastModified() > oldModified) { if (LOG.isInfoEnabled()) { LOG.info("Drop outdated index '{}'. Index timestamp is older than folder timestamp {}.", indexUri, DateUtility.format(new Date(oldModified), "yyyy-MM-dd HH:mm:ss.SSS"), DateUtility.format(new Date(newMeta.lastModified()), "yyyy-MM-dd HH:mm:ss.SSS")); } indexFileExists = false; } else { index = readIndex(indexUri, indexFile.newInputStream()); int oldFileCount = index.getKnownClasses().size(); if (newMeta.fileCount() != oldFileCount) { LOG.info("Drop divergent index '{}'. Index file count != folder file count {}.", indexUri, oldFileCount, newMeta.fileCount()); index = null; indexFileExists = false; } } break; case ALWAYS: indexFileExists = false; break; default: } } if (index == null && indexFileExists) { index = readIndex(indexUri, indexFile.newInputStream()); } if (index != null) { return index; } if (newMeta == null) { newMeta = indexMetaData(classesFolder.toPath()); } LOG.info("Rebuild index '{}'. Scanning location...", indexUri); Indexer indexer = new Indexer(); index = createFolderIndex(classesFolder.toPath(), indexer); writeIndex(index, indexFile); if (!indexFile.setLastModified(newMeta.lastModified())) { LOG.warn("Cannot set lastModified on '{}'", indexFile); } return index; } }

Target:
protected Index scanFolder(URI indexUri) throws IOException { File indexFile0 = new File(indexUri); File classesFolder = indexFile0.getParentFile().getParentFile(); try (LockedFile indexFile = new LockedFile(indexFile0)) { IndexMetaData newMeta = null; Index index = null; boolean canReadFromIndexFile = indexFile.exists(); if (canReadFromIndexFile) { switch (m_rebuildStrategy) { case IF_MODIFIED: newMeta = indexMetaData(classesFolder.toPath()); long oldModified = indexFile.lastModified(); if (newMeta.lastModified() > oldModified) { if (LOG.isInfoEnabled()) { LOG.info("Drop outdated index '{}'. Index timestamp is older than folder timestamp {}.", indexUri, DateUtility.format(new Date(oldModified), "yyyy-MM-dd HH:mm:ss.SSS"), DateUtility.format(new Date(newMeta.lastModified()), "yyyy-MM-dd HH:mm:ss.SSS")); } canReadFromIndexFile = false; } else { index = readIndex(indexUri, indexFile.newInputStream()); int oldFileCount = index.getKnownClasses().size(); if (newMeta.fileCount() != oldFileCount) { LOG.info("Drop divergent index '{}'. Index file count != folder file count {}.", indexUri, oldFileCount, newMeta.fileCount()); index = null; canReadFromIndexFile = false; } } break; case ALWAYS: canReadFromIndexFile = false; break; default: } } if (index == null && canReadFromIndexFile) { index = readIndex(indexUri, indexFile.newInputStream()); } if (index != null) { return index; } if (newMeta == null) { newMeta = indexMetaData(classesFolder.toPath()); } LOG.info("Rebuild index '{}'. Scanning location...", indexUri); Indexer indexer = new Indexer(); index = createFolderIndex(classesFolder.toPath(), indexer); writeIndex(index, indexFile); if (!indexFile.setLastModified(newMeta.lastModified())) { LOG.warn("Cannot set lastModified on '{}'", indexFile); } return index; } }