lihaosky commented on code in PR #14624:
URL: https://github.com/apache/kafka/pull/14624#discussion_r1370675126


##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamSessionWindowAggregate.java:
##########
@@ -264,23 +264,25 @@ private void fetchAndEmit(final Record<KIn, VIn> record,
                                   final long emitRangeUpperBound) {
             final long startMs = time.milliseconds();
 
+            int emittedCount = 0;
+
             // Only time ordered (indexed) session store should have 
implemented
             // this function, otherwise a not-supported exception would throw
-            final KeyValueIterator<Windowed<KIn>, VAgg> windowToEmit = store
-                .findSessions(emitRangeLowerBound, emitRangeUpperBound);
-
-            int emittedCount = 0;
-            while (windowToEmit.hasNext()) {
-                emittedCount++;
-                final KeyValue<Windowed<KIn>, VAgg> kv = windowToEmit.next();
-
-                tupleForwarder.maybeForward(
-                    record.withKey(kv.key)
-                        .withValue(new Change<>(kv.value, null))
-                        // set the timestamp as the window end timestamp
-                        .withTimestamp(kv.key.window().end())
-                        .withHeaders(record.headers()));
-            }
+            try (final KeyValueIterator<Windowed<KIn>, VAgg> windowToEmit = 
store
+                    .findSessions(emitRangeLowerBound, emitRangeUpperBound)) {
+
+                while (windowToEmit.hasNext()) {
+                    emittedCount++;
+                    final KeyValue<Windowed<KIn>, VAgg> kv = 
windowToEmit.next();
+
+                    tupleForwarder.maybeForward(
+                        record.withKey(kv.key)
+                            .withValue(new Change<>(kv.value, null))
+                            // set the timestamp as the window end timestamp
+                            .withTimestamp(kv.key.window().end())
+                            .withHeaders(record.headers()));
+                }
+          }

Review Comment:
   Is this indentation off?



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to