Source:
<code>private void cleanBaseDirsAndReadOffsetFiles() { LOG.debug("Cleaning base directories for stores."); taskStores.keySet().forEach(storeName -> { File nonLoggedStorePartitionDir = StorageManagerUtil.getStorePartitionDir(nonLoggedStoreBaseDirectory, storeName, taskModel.getTaskName()); LOG.info("Got non logged storage partition directory as " + nonLoggedStorePartitionDir.toPath().toString()); if (nonLoggedStorePartitionDir.exists()) { LOG.info("Deleting non logged storage partition directory " + nonLoggedStorePartitionDir.toPath().toString()); FileUtil.rm(nonLoggedStorePartitionDir); } File loggedStorePartitionDir = StorageManagerUtil.getStorePartitionDir(loggedStoreBaseDirectory, storeName, taskModel.getTaskName()); LOG.info("Got logged storage partition directory as " + loggedStorePartitionDir.toPath().toString()); if (!isLoggedStoreValid(storeName, loggedStorePartitionDir)) { LOG.info("Deleting logged storage partition directory " + loggedStorePartitionDir.toPath().toString()); FileUtil.rm(loggedStorePartitionDir); } else { SystemStreamPartition changelogSSP = null; <START> if (changelogSystemStreams.containsKey(storeName)) <END> changelogSSP = new SystemStreamPartition(changelogSystemStreams.get(storeName), taskModel.getChangelogPartition()); Map<SystemStreamPartition, String> offset = StorageManagerUtil.readOffsetFile(loggedStorePartitionDir, Collections.singleton(changelogSSP)); LOG.info("Read offset " + offset + " for the store " + storeName + " from logged storage partition directory " + loggedStorePartitionDir); if (offset.get(changelogSSP) != null) { fileOffsets.put( new SystemStreamPartition(changelogSystemStreams.get(storeName), taskModel.getChangelogPartition()), offset.get(changelogSSP)); } } }); }</code><technical_language>wrap code below(until updating fileOffsets) this if block? rid of scenario changelogSSP null try fetching offsets for it. rid of potential NPEs</technical_language>

Target:
private void cleanBaseDirsAndReadOffsetFiles() { LOG.debug("Cleaning base directories for stores."); taskStores.keySet().forEach(storeName -> { File nonLoggedStorePartitionDir = StorageManagerUtil.getStorePartitionDir(nonLoggedStoreBaseDirectory, storeName, taskModel.getTaskName()); LOG.info("Got non logged storage partition directory as " + nonLoggedStorePartitionDir.toPath().toString()); if (nonLoggedStorePartitionDir.exists()) { LOG.info("Deleting non logged storage partition directory " + nonLoggedStorePartitionDir.toPath().toString()); FileUtil.rm(nonLoggedStorePartitionDir); } File loggedStorePartitionDir = StorageManagerUtil.getStorePartitionDir(loggedStoreBaseDirectory, storeName, taskModel.getTaskName()); LOG.info("Got logged storage partition directory as " + loggedStorePartitionDir.toPath().toString()); if (!isLoggedStoreValid(storeName, loggedStorePartitionDir)) { LOG.info("Deleting logged storage partition directory " + loggedStorePartitionDir.toPath().toString()); FileUtil.rm(loggedStorePartitionDir); } else { SystemStreamPartition changelogSSP = new SystemStreamPartition(changelogSystemStreams.get(storeName), taskModel.getChangelogPartition()); Map<SystemStreamPartition, String> offset = StorageManagerUtil.readOffsetFile(loggedStorePartitionDir, Collections.singleton(changelogSSP)); LOG.info("Read offset for the store from logged storage partition directory {}", offset, storeName, loggedStorePartitionDir); if (offset.containsKey(changelogSSP)) { fileOffsets.put(changelogSSP, offset.get(changelogSSP)); } } }); }