@@ -3498,7 +3498,7 @@ void stopImmediately() throws InterruptedException {
34983498 }
34993499
35003500 @ Test
3501- @ SuppressWarnings ({"unchecked" , "deprecated " })
3501+ @ SuppressWarnings ({"unchecked" , "deprecation " })
35023502 public void testInvokeRecordInterceptorSuccess () throws Exception {
35033503 ConsumerFactory <Integer , String > cf = mock (ConsumerFactory .class );
35043504 Consumer <Integer , String > consumer = mock (Consumer .class );
@@ -3538,15 +3538,17 @@ public void onMessage(ConsumerRecord<Integer, String> data) {
35383538
35393539 CountDownLatch afterLatch = new CountDownLatch (1 );
35403540 RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3541+
35413542 @ Override
35423543 public ConsumerRecord <Integer , String > intercept (ConsumerRecord <Integer , String > record ) {
35433544 return record ;
35443545 }
35453546
35463547 @ Override
3547- public void clearThreadState (Consumer <Integer , String > consumer ) {
3548+ public void clearThreadState (Consumer <?, ? > consumer ) {
35483549 afterLatch .countDown ();
35493550 }
3551+
35503552 });
35513553
35523554 KafkaMessageListenerContainer <Integer , String > container =
@@ -3557,20 +3559,22 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
35573559 assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
35583560
35593561 InOrder inOrder = inOrder (recordInterceptor , messageListener , consumer );
3560- inOrder .verify (recordInterceptor ).beforePoll (eq (consumer ));
3562+ inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
35613563 inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
35623564 inOrder .verify (recordInterceptor ).intercept (eq (firstRecord ), eq (consumer ));
35633565 inOrder .verify (messageListener ).onMessage (eq (firstRecord ));
35643566 inOrder .verify (recordInterceptor ).success (eq (firstRecord ), eq (consumer ));
3567+ inOrder .verify (recordInterceptor ).afterRecord (eq (firstRecord ), eq (consumer ));
35653568 inOrder .verify (recordInterceptor ).intercept (eq (secondRecord ), eq (consumer ));
35663569 inOrder .verify (messageListener ).onMessage (eq (secondRecord ));
35673570 inOrder .verify (recordInterceptor ).success (eq (secondRecord ), eq (consumer ));
3571+ inOrder .verify (recordInterceptor ).afterRecord (eq (secondRecord ), eq (consumer ));
35683572 inOrder .verify (recordInterceptor ).clearThreadState (eq (consumer ));
35693573 container .stop ();
35703574 }
35713575
35723576 @ Test
3573- @ SuppressWarnings ({"unchecked" , "deprecated " })
3577+ @ SuppressWarnings ({"unchecked" , "deprecation " })
35743578 public void testInvokeRecordInterceptorFailure () throws Exception {
35753579 ConsumerFactory <Integer , String > cf = mock (ConsumerFactory .class );
35763580 Consumer <Integer , String > consumer = mock (Consumer .class );
@@ -3608,15 +3612,17 @@ public void onMessage(ConsumerRecord<Integer, String> data) {
36083612
36093613 CountDownLatch afterLatch = new CountDownLatch (1 );
36103614 RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3615+
36113616 @ Override
36123617 public ConsumerRecord <Integer , String > intercept (ConsumerRecord <Integer , String > record ) {
36133618 return record ;
36143619 }
36153620
36163621 @ Override
3617- public void clearThreadState (Consumer <Integer , String > consumer ) {
3622+ public void clearThreadState (Consumer <?, ? > consumer ) {
36183623 afterLatch .countDown ();
36193624 }
3625+
36203626 });
36213627
36223628 KafkaMessageListenerContainer <Integer , String > container =
@@ -3627,11 +3633,12 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
36273633 assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
36283634
36293635 InOrder inOrder = inOrder (recordInterceptor , messageListener , consumer );
3630- inOrder .verify (recordInterceptor ).beforePoll (eq (consumer ));
3636+ inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
36313637 inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
36323638 inOrder .verify (recordInterceptor ).intercept (eq (record ), eq (consumer ));
36333639 inOrder .verify (messageListener ).onMessage (eq (record ));
36343640 inOrder .verify (recordInterceptor ).failure (eq (record ), any (), eq (consumer ));
3641+ inOrder .verify (recordInterceptor ).afterRecord (eq (record ), eq (consumer ));
36353642 inOrder .verify (recordInterceptor ).clearThreadState (eq (consumer ));
36363643 container .stop ();
36373644 }
@@ -3677,14 +3684,17 @@ public void onMessage(List<ConsumerRecord<Integer, String>> data) {
36773684 BatchInterceptor <Integer , String > batchInterceptor = spy (new BatchInterceptor <Integer , String >() {
36783685
36793686 @ Override
3680- public ConsumerRecords <Integer , String > intercept (ConsumerRecords <Integer , String > records , Consumer <Integer , String > consumer ) {
3687+ public ConsumerRecords <Integer , String > intercept (ConsumerRecords <Integer , String > records ,
3688+ Consumer <Integer , String > consumer ) {
3689+
36813690 return records ;
36823691 }
36833692
36843693 @ Override
3685- public void clearThreadState (Consumer <Integer , String > consumer ) {
3694+ public void clearThreadState (Consumer <?, ? > consumer ) {
36863695 afterLatch .countDown ();
36873696 }
3697+
36883698 });
36893699
36903700 KafkaMessageListenerContainer <Integer , String > container =
@@ -3695,7 +3705,7 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
36953705 assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
36963706
36973707 InOrder inOrder = inOrder (batchInterceptor , batchMessageListener , consumer );
3698- inOrder .verify (batchInterceptor ).beforePoll (eq (consumer ));
3708+ inOrder .verify (batchInterceptor ).setupThreadState (eq (consumer ));
36993709 inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
37003710 inOrder .verify (batchInterceptor ).intercept (eq (consumerRecords ), eq (consumer ));
37013711 inOrder .verify (batchMessageListener ).onMessage (eq (List .of (firstRecord , secondRecord )));
@@ -3743,8 +3753,7 @@ public void onMessage(List<ConsumerRecord<Integer, String>> data) {
37433753 containerProps .setClientId ("clientId" );
37443754
37453755 CountDownLatch afterLatch = new CountDownLatch (1 );
3746- BatchInterceptor <Integer , String > batchInterceptor = spy (
3747- new BatchInterceptor <Integer , String >() {
3756+ BatchInterceptor <Integer , String > batchInterceptor = spy (new BatchInterceptor <Integer , String >() {
37483757
37493758 @ Override
37503759 public ConsumerRecords <Integer , String > intercept (ConsumerRecords <Integer , String > records ,
@@ -3753,9 +3762,10 @@ public ConsumerRecords<Integer, String> intercept(ConsumerRecords<Integer, Strin
37533762 }
37543763
37553764 @ Override
3756- public void clearThreadState (Consumer <Integer , String > consumer ) {
3765+ public void clearThreadState (Consumer <?, ? > consumer ) {
37573766 afterLatch .countDown ();
37583767 }
3768+
37593769 });
37603770
37613771 KafkaMessageListenerContainer <Integer , String > container =
@@ -3766,7 +3776,7 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
37663776 assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
37673777
37683778 InOrder inOrder = inOrder (batchInterceptor , batchMessageListener , consumer );
3769- inOrder .verify (batchInterceptor ).beforePoll (eq (consumer ));
3779+ inOrder .verify (batchInterceptor ).setupThreadState (eq (consumer ));
37703780 inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
37713781 inOrder .verify (batchInterceptor ).intercept (eq (consumerRecords ), eq (consumer ));
37723782 inOrder .verify (batchMessageListener ).onMessage (eq (List .of (firstRecord , secondRecord )));
0 commit comments