From 66ca0743ed3f537028a1f42a2d0b82cb3e7c4182 Mon Sep 17 00:00:00 2001 From: abilan Date: Thu, 1 Dec 2022 12:24:11 -0500 Subject: [PATCH] Fix deprecation for `RetryListenerSupport` Related to https://github.com/spring-projects/spring-retry/pull/326 --- .../kafka/inbound/InboundGatewayTests.java | 17 +++++++---------- .../inbound/MessageDrivenAdapterTests.java | 5 +++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/InboundGatewayTests.java b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/InboundGatewayTests.java index 58dca679ff..ff0d21c833 100644 --- a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/InboundGatewayTests.java +++ b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/InboundGatewayTests.java @@ -56,8 +56,8 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.ErrorMessage; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; +import org.springframework.retry.RetryListener; import org.springframework.retry.backoff.NoBackOffPolicy; -import org.springframework.retry.listener.RetryListenerSupport; import org.springframework.retry.policy.SimpleRetryPolicy; import org.springframework.retry.support.RetryTemplate; @@ -379,14 +379,10 @@ class InboundGatewayTests { KafkaTemplate template = new KafkaTemplate<>(pf); template.setDefaultTopic(topic7); KafkaInboundGateway gateway = new KafkaInboundGateway<>(container, template); - MessageChannel out = new DirectChannel() { - - @Override - protected boolean doSend(Message message, long timeout) { - throw new RuntimeException("intended"); - } - - }; + MessageChannel out = + (message, timeout) -> { + throw new RuntimeException("intended"); + }; gateway.setRequestChannel(out); gateway.setBeanFactory(mock(BeanFactory.class)); gateway.setReplyTimeout(30_000); @@ -396,11 +392,12 @@ class InboundGatewayTests { retryTemplate.setRetryPolicy(retryPolicy); retryTemplate.setBackOffPolicy(new NoBackOffPolicy()); final CountDownLatch retryCountLatch = new CountDownLatch(retryPolicy.getMaxAttempts()); - retryTemplate.registerListener(new RetryListenerSupport() { + retryTemplate.registerListener(new RetryListener() { @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { + retryCountLatch.countDown(); } }); diff --git a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/MessageDrivenAdapterTests.java b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/MessageDrivenAdapterTests.java index 443b2aea18..818da37a39 100644 --- a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/MessageDrivenAdapterTests.java +++ b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/MessageDrivenAdapterTests.java @@ -83,7 +83,7 @@ import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.ErrorMessage; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; -import org.springframework.retry.listener.RetryListenerSupport; +import org.springframework.retry.RetryListener; import org.springframework.retry.policy.SimpleRetryPolicy; import org.springframework.retry.support.RetryTemplate; @@ -310,11 +310,12 @@ class MessageDrivenAdapterTests { retryPolicy.setMaxAttempts(2); retryTemplate.setRetryPolicy(retryPolicy); final CountDownLatch retryCountLatch = new CountDownLatch(retryPolicy.getMaxAttempts()); - retryTemplate.registerListener(new RetryListenerSupport() { + retryTemplate.registerListener(new RetryListener() { @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { + retryCountLatch.countDown(); } });