@@ -3498,7 +3498,7 @@ void stopImmediately() throws InterruptedException {
3498
3498
}
3499
3499
3500
3500
@ Test
3501
- @ SuppressWarnings ({"unchecked" , "deprecated " })
3501
+ @ SuppressWarnings ({"unchecked" , "deprecation " })
3502
3502
public void testInvokeRecordInterceptorSuccess () throws Exception {
3503
3503
ConsumerFactory <Integer , String > cf = mock (ConsumerFactory .class );
3504
3504
Consumer <Integer , String > consumer = mock (Consumer .class );
@@ -3538,15 +3538,17 @@ public void onMessage(ConsumerRecord<Integer, String> data) {
3538
3538
3539
3539
CountDownLatch afterLatch = new CountDownLatch (1 );
3540
3540
RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3541
+
3541
3542
@ Override
3542
3543
public ConsumerRecord <Integer , String > intercept (ConsumerRecord <Integer , String > record ) {
3543
3544
return record ;
3544
3545
}
3545
3546
3546
3547
@ Override
3547
- public void clearThreadState (Consumer <Integer , String > consumer ) {
3548
+ public void clearThreadState (Consumer <?, ? > consumer ) {
3548
3549
afterLatch .countDown ();
3549
3550
}
3551
+
3550
3552
});
3551
3553
3552
3554
KafkaMessageListenerContainer <Integer , String > container =
@@ -3557,20 +3559,22 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
3557
3559
assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
3558
3560
3559
3561
InOrder inOrder = inOrder (recordInterceptor , messageListener , consumer );
3560
- inOrder .verify (recordInterceptor ).beforePoll (eq (consumer ));
3562
+ inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
3561
3563
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3562
3564
inOrder .verify (recordInterceptor ).intercept (eq (firstRecord ), eq (consumer ));
3563
3565
inOrder .verify (messageListener ).onMessage (eq (firstRecord ));
3564
3566
inOrder .verify (recordInterceptor ).success (eq (firstRecord ), eq (consumer ));
3567
+ inOrder .verify (recordInterceptor ).afterRecord (eq (firstRecord ), eq (consumer ));
3565
3568
inOrder .verify (recordInterceptor ).intercept (eq (secondRecord ), eq (consumer ));
3566
3569
inOrder .verify (messageListener ).onMessage (eq (secondRecord ));
3567
3570
inOrder .verify (recordInterceptor ).success (eq (secondRecord ), eq (consumer ));
3571
+ inOrder .verify (recordInterceptor ).afterRecord (eq (secondRecord ), eq (consumer ));
3568
3572
inOrder .verify (recordInterceptor ).clearThreadState (eq (consumer ));
3569
3573
container .stop ();
3570
3574
}
3571
3575
3572
3576
@ Test
3573
- @ SuppressWarnings ({"unchecked" , "deprecated " })
3577
+ @ SuppressWarnings ({"unchecked" , "deprecation " })
3574
3578
public void testInvokeRecordInterceptorFailure () throws Exception {
3575
3579
ConsumerFactory <Integer , String > cf = mock (ConsumerFactory .class );
3576
3580
Consumer <Integer , String > consumer = mock (Consumer .class );
@@ -3608,15 +3612,17 @@ public void onMessage(ConsumerRecord<Integer, String> data) {
3608
3612
3609
3613
CountDownLatch afterLatch = new CountDownLatch (1 );
3610
3614
RecordInterceptor <Integer , String > recordInterceptor = spy (new RecordInterceptor <Integer , String >() {
3615
+
3611
3616
@ Override
3612
3617
public ConsumerRecord <Integer , String > intercept (ConsumerRecord <Integer , String > record ) {
3613
3618
return record ;
3614
3619
}
3615
3620
3616
3621
@ Override
3617
- public void clearThreadState (Consumer <Integer , String > consumer ) {
3622
+ public void clearThreadState (Consumer <?, ? > consumer ) {
3618
3623
afterLatch .countDown ();
3619
3624
}
3625
+
3620
3626
});
3621
3627
3622
3628
KafkaMessageListenerContainer <Integer , String > container =
@@ -3627,11 +3633,12 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
3627
3633
assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
3628
3634
3629
3635
InOrder inOrder = inOrder (recordInterceptor , messageListener , consumer );
3630
- inOrder .verify (recordInterceptor ).beforePoll (eq (consumer ));
3636
+ inOrder .verify (recordInterceptor ).setupThreadState (eq (consumer ));
3631
3637
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3632
3638
inOrder .verify (recordInterceptor ).intercept (eq (record ), eq (consumer ));
3633
3639
inOrder .verify (messageListener ).onMessage (eq (record ));
3634
3640
inOrder .verify (recordInterceptor ).failure (eq (record ), any (), eq (consumer ));
3641
+ inOrder .verify (recordInterceptor ).afterRecord (eq (record ), eq (consumer ));
3635
3642
inOrder .verify (recordInterceptor ).clearThreadState (eq (consumer ));
3636
3643
container .stop ();
3637
3644
}
@@ -3677,14 +3684,17 @@ public void onMessage(List<ConsumerRecord<Integer, String>> data) {
3677
3684
BatchInterceptor <Integer , String > batchInterceptor = spy (new BatchInterceptor <Integer , String >() {
3678
3685
3679
3686
@ 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
+
3681
3690
return records ;
3682
3691
}
3683
3692
3684
3693
@ Override
3685
- public void clearThreadState (Consumer <Integer , String > consumer ) {
3694
+ public void clearThreadState (Consumer <?, ? > consumer ) {
3686
3695
afterLatch .countDown ();
3687
3696
}
3697
+
3688
3698
});
3689
3699
3690
3700
KafkaMessageListenerContainer <Integer , String > container =
@@ -3695,7 +3705,7 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
3695
3705
assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
3696
3706
3697
3707
InOrder inOrder = inOrder (batchInterceptor , batchMessageListener , consumer );
3698
- inOrder .verify (batchInterceptor ).beforePoll (eq (consumer ));
3708
+ inOrder .verify (batchInterceptor ).setupThreadState (eq (consumer ));
3699
3709
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3700
3710
inOrder .verify (batchInterceptor ).intercept (eq (consumerRecords ), eq (consumer ));
3701
3711
inOrder .verify (batchMessageListener ).onMessage (eq (List .of (firstRecord , secondRecord )));
@@ -3743,8 +3753,7 @@ public void onMessage(List<ConsumerRecord<Integer, String>> data) {
3743
3753
containerProps .setClientId ("clientId" );
3744
3754
3745
3755
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 >() {
3748
3757
3749
3758
@ Override
3750
3759
public ConsumerRecords <Integer , String > intercept (ConsumerRecords <Integer , String > records ,
@@ -3753,9 +3762,10 @@ public ConsumerRecords<Integer, String> intercept(ConsumerRecords<Integer, Strin
3753
3762
}
3754
3763
3755
3764
@ Override
3756
- public void clearThreadState (Consumer <Integer , String > consumer ) {
3765
+ public void clearThreadState (Consumer <?, ? > consumer ) {
3757
3766
afterLatch .countDown ();
3758
3767
}
3768
+
3759
3769
});
3760
3770
3761
3771
KafkaMessageListenerContainer <Integer , String > container =
@@ -3766,7 +3776,7 @@ public void clearThreadState(Consumer<Integer, String> consumer) {
3766
3776
assertThat (afterLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
3767
3777
3768
3778
InOrder inOrder = inOrder (batchInterceptor , batchMessageListener , consumer );
3769
- inOrder .verify (batchInterceptor ).beforePoll (eq (consumer ));
3779
+ inOrder .verify (batchInterceptor ).setupThreadState (eq (consumer ));
3770
3780
inOrder .verify (consumer ).poll (Duration .ofMillis (ContainerProperties .DEFAULT_POLL_TIMEOUT ));
3771
3781
inOrder .verify (batchInterceptor ).intercept (eq (consumerRecords ), eq (consumer ));
3772
3782
inOrder .verify (batchMessageListener ).onMessage (eq (List .of (firstRecord , secondRecord )));
0 commit comments