ableegoldman commented on a change in pull request #10609: URL: https://github.com/apache/kafka/pull/10609#discussion_r636557299
########## File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java ########## @@ -462,39 +512,49 @@ private void cleanRemovedTasksCalledByUser() throws Exception { * List all of the task directories that are non-empty * @return The list of all the non-empty local directories for stream tasks */ - File[] listNonEmptyTaskDirectories() { - final File[] taskDirectories; - if (!hasPersistentStores || !stateDir.exists()) { - taskDirectories = new File[0]; - } else { - taskDirectories = - stateDir.listFiles(pathname -> { - if (!pathname.isDirectory() || !TASK_DIR_PATH_NAME.matcher(pathname.getName()).matches()) { - return false; - } else { - return !taskDirIsEmpty(pathname); - } - }); - } - - return taskDirectories == null ? new File[0] : taskDirectories; + List<TaskDirectory> listNonEmptyTaskDirectories() { + return listTaskDirectories(pathname -> { + if (!pathname.isDirectory() || !TASK_DIR_PATH_NAME.matcher(pathname.getName()).matches()) { + return false; + } else { + return !taskDirIsEmpty(pathname); + } + }); } /** - * List all of the task directories + * List all of the task directories along with their parent directory if they belong to a named topology * @return The list of all the existing local directories for stream tasks */ - File[] listAllTaskDirectories() { - final File[] taskDirectories; - if (!hasPersistentStores || !stateDir.exists()) { - taskDirectories = new File[0]; - } else { - taskDirectories = - stateDir.listFiles(pathname -> pathname.isDirectory() - && TASK_DIR_PATH_NAME.matcher(pathname.getName()).matches()); + List<TaskDirectory> listAllTaskDirectories() { + return listTaskDirectories(pathname -> pathname.isDirectory() && TASK_DIR_PATH_NAME.matcher(pathname.getName()).matches()); + } + + private List<TaskDirectory> listTaskDirectories(final FileFilter filter) { + final List<TaskDirectory> taskDirectories = new ArrayList<>(); + if (hasPersistentStores && stateDir.exists()) { + if (hasNamedTopologies) { Review comment: No, that should not be allowed. We have checks to verify this in a few places where it matters, but it's an assumption we can make here. I'm not sure if your question was from an implementation point of view or a semantic one, but I can further clarify or justify why it should not be allowed if you want -- 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: us...@infra.apache.org