kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mj...@apache.org
Subject [kafka] branch 1.1 updated: MINOR: fixed missing close of Iterator, used try-with-resource where appropriate (#6562)
Date Wed, 17 Apr 2019 00:00:57 GMT
This is an automated email from the ASF dual-hosted git repository.

mjsax pushed a commit to branch 1.1
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/1.1 by this push:
     new dded84a  MINOR: fixed missing close of Iterator, used try-with-resource where appropriate
(#6562)
dded84a is described below

commit dded84a52e7971727180a01600e8bf10f8343e0b
Author: pkleindl <44436474+pkleindl@users.noreply.github.com>
AuthorDate: Wed Apr 17 01:44:17 2019 +0200

    MINOR: fixed missing close of Iterator, used try-with-resource where appropriate (#6562)
    
    Reviewers: Matthias J. Sax <matthias@confluent.io>, Guozhang Wang <guozhang@confluent.io>
---
 .../apache/kafka/streams/TopologyTestDriverTest.java   | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/streams/test-utils/src/test/java/org/apache/kafka/streams/TopologyTestDriverTest.java
b/streams/test-utils/src/test/java/org/apache/kafka/streams/TopologyTestDriverTest.java
index 71c9a19..d3659a9 100644
--- a/streams/test-utils/src/test/java/org/apache/kafka/streams/TopologyTestDriverTest.java
+++ b/streams/test-utils/src/test/java/org/apache/kafka/streams/TopologyTestDriverTest.java
@@ -853,10 +853,11 @@ public class TopologyTestDriverTest {
         }
 
         private void flushStore() {
-            final KeyValueIterator<String, Long> it = store.all();
-            while (it.hasNext()) {
-                final KeyValue<String, Long> next = it.next();
-                context.forward(next.key, next.value);
+            try (final KeyValueIterator<String, Long> it = store.all()) {
+                while (it.hasNext()) {
+                    final KeyValue<String, Long> next = it.next();
+                    context.forward(next.key, next.value);
+                }
             }
         }
 
@@ -909,21 +910,20 @@ public class TopologyTestDriverTest {
         config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
         config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.Long().getClass().getName());
 
-        {
-            final TopologyTestDriver testDriver = new TopologyTestDriver(topology, config);
+        try (final TopologyTestDriver testDriver = new TopologyTestDriver(topology, config))
{
             Assert.assertNull(testDriver.getKeyValueStore("storeProcessorStore").get("a"));
             testDriver.pipeInput(recordFactory.create("input-topic", "a", 1L));
             Assert.assertEquals(1L, testDriver.getKeyValueStore("storeProcessorStore").get("a"));
-            testDriver.close();
         }
 
-        {
-            final TopologyTestDriver testDriver = new TopologyTestDriver(topology, config);
+
+        try (final TopologyTestDriver testDriver = new TopologyTestDriver(topology, config))
{
             Assert.assertNull(
                 "Closing the prior test driver should have cleaned up this store and value.",
                 testDriver.getKeyValueStore("storeProcessorStore").get("a")
             );
         }
+
     }
     
     @Test


Mime
View raw message