This is an automated email from the ASF dual-hosted git repository. mjsax pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push: new 5919e73 MINOR: fixed missing close of Iterator, used try-with-resource where appropriate (#6562) 5919e73 is described below commit 5919e73e5d2ebdf3d3fcefcb691b0718bcce34bb Author: pkleindl <44436474+pklei...@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 <matth...@confluent.io>, Guozhang Wang <guozh...@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 6f6c51e..d577cf7 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 @@ -875,10 +875,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); + } } } @@ -942,21 +943,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