dima5rr commented on a change in pull request #9020: URL: https://github.com/apache/kafka/pull/9020#discussion_r455974476
########## File path: streams/src/main/java/org/apache/kafka/streams/state/internals/StreamThreadStateStoreProvider.java ########## @@ -51,18 +51,22 @@ public StreamThreadStateStoreProvider(final StreamThread streamThread) { final StreamThread.State state = streamThread.state(); if (storeQueryParams.staleStoresEnabled() ? state.isAlive() : state == StreamThread.State.RUNNING) { final Map<TaskId, ? extends Task> tasks = storeQueryParams.staleStoresEnabled() ? streamThread.allTasks() : streamThread.activeTaskMap(); + final List<T> stores = new ArrayList<>(); if (storeQueryParams.partition() != null) { final Task streamTask = findStreamTask(tasks, storeName, storeQueryParams.partition()); - if (streamTask == null) { - return Collections.emptyList(); + if (streamTask != null) { + final T store = validateAndListStores(streamTask.getStore(storeName), queryableStoreType, storeName, streamTask.id()); + if (store != null) { + stores.add(store); + } } - final T store = validateAndListStores(streamTask.getStore(storeName), queryableStoreType, storeName, streamTask.id()); - return store != null ? Collections.singletonList(store) : Collections.emptyList(); + } else { + tasks.values().stream(). + map(streamTask -> validateAndListStores(streamTask.getStore(storeName), queryableStoreType, storeName, streamTask.id())). + filter(Objects::nonNull). + forEach(stores::add); } - return tasks.values().stream(). - map(streamTask -> validateAndListStores(streamTask.getStore(storeName), queryableStoreType, storeName, streamTask.id())). - filter(Objects::nonNull). - collect(Collectors.toList()); + return Collections.unmodifiableList(stores); Review comment: Will concise it into functional way. ---------------------------------------------------------------- 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