2222import java .util .List ;
2323import java .util .Map ;
2424import java .util .Properties ;
25- import java .util .concurrent .CompletableFuture ;
2625import java .util .concurrent .ExecutionException ;
2726
2827import org .apache .kafka .clients .admin .NewTopic ;
4039import org .springframework .kafka .core .DefaultKafkaProducerFactory ;
4140import org .springframework .kafka .core .KafkaTemplate ;
4241import 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 ;
4748
4849import static org .hamcrest .MatcherAssert .assertThat ;
4950import static org .hamcrest .Matchers .containsInAnyOrder ;
@@ -142,12 +143,12 @@ void testValidation() {
142143 @ Test
143144 void testReadFromSinglePartition () throws ExecutionException , InterruptedException {
144145 this .template .setDefaultTopic ("topic1" );
145- var futures = new ArrayList <CompletableFuture <?> >();
146+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
146147 futures .add (this .template .sendDefault ("val0" ));
147148 futures .add (this .template .sendDefault ("val1" ));
148149 futures .add (this .template .sendDefault ("val2" ));
149150 futures .add (this .template .sendDefault ("val3" ));
150- for (var future : futures ) {
151+ for (ListenableFuture < SendResult < String , String >> future : futures ) {
151152 future .get ();
152153 }
153154
@@ -176,12 +177,12 @@ void testReadFromSinglePartition() throws ExecutionException, InterruptedExcepti
176177 @ Test
177178 void testReadFromSinglePartitionFromCustomOffset () throws ExecutionException , InterruptedException {
178179 this .template .setDefaultTopic ("topic5" );
179- var futures = new ArrayList <CompletableFuture <?> >();
180+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
180181 futures .add (this .template .sendDefault ("val0" )); // <-- offset 0
181182 futures .add (this .template .sendDefault ("val1" )); // <-- offset 1
182183 futures .add (this .template .sendDefault ("val2" )); // <-- offset 2
183184 futures .add (this .template .sendDefault ("val3" )); // <-- offset 3
184- for (var future : futures ) {
185+ for (ListenableFuture < SendResult < String , String >> future : futures ) {
185186 future .get ();
186187 }
187188
@@ -212,10 +213,10 @@ void testReadFromSinglePartitionFromTheOffsetStoredInKafka() throws Exception {
212213 // first run: read a topic from the beginning
213214
214215 this .template .setDefaultTopic ("topic6" );
215- var futures = new ArrayList <CompletableFuture <?> >();
216+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
216217 futures .add (this .template .sendDefault ("val0" )); // <-- offset 0
217218 futures .add (this .template .sendDefault ("val1" )); // <-- offset 1
218- for (var future : futures ) {
219+ for (ListenableFuture < SendResult < String , String >> future : futures ) {
219220 future .get ();
220221 }
221222 this .reader = new KafkaItemReader <>(this .consumerProperties , "topic6" , 0 );
@@ -266,12 +267,12 @@ void testReadFromSinglePartitionFromTheOffsetStoredInKafka() throws Exception {
266267 @ Test
267268 void testReadFromMultiplePartitions () throws ExecutionException , InterruptedException {
268269 this .template .setDefaultTopic ("topic2" );
269- var futures = new ArrayList <CompletableFuture <?> >();
270+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
270271 futures .add (this .template .sendDefault ("val0" ));
271272 futures .add (this .template .sendDefault ("val1" ));
272273 futures .add (this .template .sendDefault ("val2" ));
273274 futures .add (this .template .sendDefault ("val3" ));
274- for (var future : futures ) {
275+ for (ListenableFuture < SendResult < String , String >> future : futures ) {
275276 future .get ();
276277 }
277278
@@ -294,13 +295,13 @@ void testReadFromMultiplePartitions() throws ExecutionException, InterruptedExce
294295 @ Test
295296 void testReadFromSinglePartitionAfterRestart () throws ExecutionException , InterruptedException {
296297 this .template .setDefaultTopic ("topic3" );
297- var futures = new ArrayList <CompletableFuture <?> >();
298+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
298299 futures .add (this .template .sendDefault ("val0" ));
299300 futures .add (this .template .sendDefault ("val1" ));
300301 futures .add (this .template .sendDefault ("val2" ));
301302 futures .add (this .template .sendDefault ("val3" ));
302303 futures .add (this .template .sendDefault ("val4" ));
303- for (var future : futures ) {
304+ for (ListenableFuture < SendResult < String , String >> future : futures ) {
304305 future .get ();
305306 }
306307 ExecutionContext executionContext = new ExecutionContext ();
@@ -330,7 +331,7 @@ void testReadFromSinglePartitionAfterRestart() throws ExecutionException, Interr
330331
331332 @ Test
332333 void testReadFromMultiplePartitionsAfterRestart () throws ExecutionException , InterruptedException {
333- var futures = new ArrayList <CompletableFuture <?> >();
334+ List < ListenableFuture < SendResult < String , String >>> futures = new ArrayList <>();
334335 futures .add (this .template .send ("topic4" , 0 , null , "val0" ));
335336 futures .add (this .template .send ("topic4" , 0 , null , "val2" ));
336337 futures .add (this .template .send ("topic4" , 0 , null , "val4" ));
@@ -340,7 +341,7 @@ void testReadFromMultiplePartitionsAfterRestart() throws ExecutionException, Int
340341 futures .add (this .template .send ("topic4" , 1 , null , "val5" ));
341342 futures .add (this .template .send ("topic4" , 1 , null , "val7" ));
342343
343- for (var future : futures ) {
344+ for (ListenableFuture <?> future : futures ) {
344345 future .get ();
345346 }
346347
0 commit comments