File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
tests/src/main/kotlin/io/streamthoughts/kafka/tests Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -217,16 +217,16 @@ class TestingEmbeddedKafka(config: Properties = Properties()) {
217
217
valueDeserializer : Deserializer <V >? = null,
218
218
consumerConfig : Map <String , Any ?> = emptyMap()): List <ConsumerRecord <K , V >> {
219
219
220
- val consumer = consumerClient(consumerConfig, keyDeserializer, valueDeserializer)
221
- consumer.subscribe(listOf (topic))
222
- val records : MutableList <ConsumerRecord <K , V >> = mutableListOf ()
223
-
224
- val begin = System .currentTimeMillis()
225
- while ( (System .currentTimeMillis() - begin) < timeout.toMillis() && records.size < expectedNumRecords) {
226
- consumer.poll(Duration .ofMillis(100 )).forEach { records.add(it) }
227
- }
228
- return records
220
+ consumerClient(consumerConfig, keyDeserializer, valueDeserializer).use { client ->
221
+ client.subscribe(listOf (topic))
222
+ val records: MutableList <ConsumerRecord <K , V >> = mutableListOf ()
229
223
224
+ val begin = System .currentTimeMillis()
225
+ while ((System .currentTimeMillis() - begin) < timeout.toMillis() && records.size < expectedNumRecords) {
226
+ client.poll(Duration .ofMillis(100 )).forEach { records.add(it) }
227
+ }
228
+ return records
229
+ }
230
230
}
231
231
232
232
/* *
You can’t perform that action at this time.
0 commit comments