2222import java .util .List ;
2323import java .util .Map ;
2424import java .util .Properties ;
25+ import java .util .concurrent .CompletableFuture ;
2526import java .util .concurrent .ExecutionException ;
2627
2728import org .apache .kafka .clients .admin .NewTopic ;
3940import org .springframework .kafka .core .DefaultKafkaProducerFactory ;
4041import org .springframework .kafka .core .KafkaTemplate ;
4142import org .springframework .kafka .core .ProducerFactory ;
42- import org .springframework .kafka .support .SendResult ;
4343import org .springframework .kafka .test .EmbeddedKafkaBroker ;
4444import org .springframework .kafka .test .context .EmbeddedKafka ;
4545import org .springframework .kafka .test .utils .KafkaTestUtils ;
4646import org .springframework .test .context .junit .jupiter .SpringExtension ;
47- import org .springframework .util .concurrent .ListenableFuture ;
4847
4948import static org .hamcrest .MatcherAssert .assertThat ;
5049import static org .hamcrest .Matchers .containsInAnyOrder ;
@@ -143,12 +142,12 @@ void testValidation() {
143142 @ Test
144143 void testReadFromSinglePartition () throws ExecutionException , InterruptedException {
145144 this .template .setDefaultTopic ("topic1" );
146- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
145+ var futures = new ArrayList <CompletableFuture <?> >();
147146 futures .add (this .template .sendDefault ("val0" ));
148147 futures .add (this .template .sendDefault ("val1" ));
149148 futures .add (this .template .sendDefault ("val2" ));
150149 futures .add (this .template .sendDefault ("val3" ));
151- for (ListenableFuture < SendResult < String , String >> future : futures ) {
150+ for (var future : futures ) {
152151 future .get ();
153152 }
154153
@@ -177,12 +176,12 @@ void testReadFromSinglePartition() throws ExecutionException, InterruptedExcepti
177176 @ Test
178177 void testReadFromSinglePartitionFromCustomOffset () throws ExecutionException , InterruptedException {
179178 this .template .setDefaultTopic ("topic5" );
180- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
179+ var futures = new ArrayList <CompletableFuture <?> >();
181180 futures .add (this .template .sendDefault ("val0" )); // <-- offset 0
182181 futures .add (this .template .sendDefault ("val1" )); // <-- offset 1
183182 futures .add (this .template .sendDefault ("val2" )); // <-- offset 2
184183 futures .add (this .template .sendDefault ("val3" )); // <-- offset 3
185- for (ListenableFuture < SendResult < String , String >> future : futures ) {
184+ for (var future : futures ) {
186185 future .get ();
187186 }
188187
@@ -213,10 +212,10 @@ void testReadFromSinglePartitionFromTheOffsetStoredInKafka() throws Exception {
213212 // first run: read a topic from the beginning
214213
215214 this .template .setDefaultTopic ("topic6" );
216- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
215+ var futures = new ArrayList <CompletableFuture <?> >();
217216 futures .add (this .template .sendDefault ("val0" )); // <-- offset 0
218217 futures .add (this .template .sendDefault ("val1" )); // <-- offset 1
219- for (ListenableFuture < SendResult < String , String >> future : futures ) {
218+ for (var future : futures ) {
220219 future .get ();
221220 }
222221 this .reader = new KafkaItemReader <>(this .consumerProperties , "topic6" , 0 );
@@ -267,12 +266,12 @@ void testReadFromSinglePartitionFromTheOffsetStoredInKafka() throws Exception {
267266 @ Test
268267 void testReadFromMultiplePartitions () throws ExecutionException , InterruptedException {
269268 this .template .setDefaultTopic ("topic2" );
270- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
269+ var futures = new ArrayList <CompletableFuture <?> >();
271270 futures .add (this .template .sendDefault ("val0" ));
272271 futures .add (this .template .sendDefault ("val1" ));
273272 futures .add (this .template .sendDefault ("val2" ));
274273 futures .add (this .template .sendDefault ("val3" ));
275- for (ListenableFuture < SendResult < String , String >> future : futures ) {
274+ for (var future : futures ) {
276275 future .get ();
277276 }
278277
@@ -295,13 +294,13 @@ void testReadFromMultiplePartitions() throws ExecutionException, InterruptedExce
295294 @ Test
296295 void testReadFromSinglePartitionAfterRestart () throws ExecutionException , InterruptedException {
297296 this .template .setDefaultTopic ("topic3" );
298- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
297+ var futures = new ArrayList <CompletableFuture <?> >();
299298 futures .add (this .template .sendDefault ("val0" ));
300299 futures .add (this .template .sendDefault ("val1" ));
301300 futures .add (this .template .sendDefault ("val2" ));
302301 futures .add (this .template .sendDefault ("val3" ));
303302 futures .add (this .template .sendDefault ("val4" ));
304- for (ListenableFuture < SendResult < String , String >> future : futures ) {
303+ for (var future : futures ) {
305304 future .get ();
306305 }
307306 ExecutionContext executionContext = new ExecutionContext ();
@@ -331,7 +330,7 @@ void testReadFromSinglePartitionAfterRestart() throws ExecutionException, Interr
331330
332331 @ Test
333332 void testReadFromMultiplePartitionsAfterRestart () throws ExecutionException , InterruptedException {
334- List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
333+ var futures = new ArrayList <CompletableFuture <?> >();
335334 futures .add (this .template .send ("topic4" , 0 , null , "val0" ));
336335 futures .add (this .template .send ("topic4" , 0 , null , "val2" ));
337336 futures .add (this .template .send ("topic4" , 0 , null , "val4" ));
@@ -341,7 +340,7 @@ void testReadFromMultiplePartitionsAfterRestart() throws ExecutionException, Int
341340 futures .add (this .template .send ("topic4" , 1 , null , "val5" ));
342341 futures .add (this .template .send ("topic4" , 1 , null , "val7" ));
343342
344- for (ListenableFuture <?> future : futures ) {
343+ for (var future : futures ) {
345344 future .get ();
346345 }
347346
0 commit comments