From 7a84d6797e9a144161c1b985c08028352cf469f2 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 13 Jan 2021 14:59:54 -0500 Subject: [PATCH] Upgrade to spring-amqp 2.3.4 - remove uses of deprecated method - correctly call delegate in correlation data wrapper **Cherry-pick to `5.4.x`** --- build.gradle | 2 +- .../amqp/outbound/AbstractAmqpOutboundEndpoint.java | 11 ++++++++++- .../amqp/outbound/AmqpOutboundEndpoint.java | 4 ++-- .../amqp/outbound/AsyncAmqpOutboundGateway.java | 4 ++-- .../amqp/outbound/AmqpOutboundEndpointTests.java | 4 ++-- .../amqp/outbound/AmqpOutboundEndpointTests2.java | 4 ++-- .../amqp/outbound/AsyncAmqpGatewayTests.java | 4 ++-- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 69a5b59daf..af44f05753 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,7 @@ ext { servletApiVersion = '4.0.1' smackVersion = '4.3.5' soapVersion = '1.4.0' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.1' + springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.4' springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2021.0.0-SNAPSHOT' springKafkaVersion = '2.7.0-SNAPSHOT' springRetryVersion = '1.3.0' diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AbstractAmqpOutboundEndpoint.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AbstractAmqpOutboundEndpoint.java index 4ce8188787..c1f0e1ff98 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AbstractAmqpOutboundEndpoint.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AbstractAmqpOutboundEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -730,6 +730,7 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin } @Override + @Deprecated public void setReturnedMessage(org.springframework.amqp.core.Message returnedMessage) { if (this.userData instanceof CorrelationData) { ((CorrelationData) this.userData).setReturnedMessage(returnedMessage); @@ -737,6 +738,14 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin super.setReturnedMessage(returnedMessage); } + @Override + public void setReturned(ReturnedMessage returned) { + if (this.userData instanceof CorrelationData) { + ((CorrelationData) this.userData).setReturned(returned); + } + super.setReturned(returned); + } + } } diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java index 73c5eafc85..78b2444b43 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -201,7 +201,7 @@ public class AmqpOutboundEndpoint extends AbstractAmqpOutboundEndpoint if (!confirm.isAck()) { throw new AmqpException("Negative publisher confirm received: " + confirm); } - if (correlationData.getReturnedMessage() != null) { + if (correlationData.getReturned() != null) { throw new AmqpException("Message was returned by the broker"); } } diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AsyncAmqpOutboundGateway.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AsyncAmqpOutboundGateway.java index 592afee1b8..f05e6cfa31 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AsyncAmqpOutboundGateway.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AsyncAmqpOutboundGateway.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ public class AsyncAmqpOutboundGateway extends AbstractAmqpOutboundEndpoint { AsyncAmqpOutboundGateway.this.messageConverter); sendOutput(returnedMessage, returnChannel, true); } - this.correlationData.setReturnedMessage(amre.getReturnedMessage()); + this.correlationData.setReturned(amre.getReturned()); /* * Complete the user's future (if present) since the async template will only complete * once, successfully, or with a failure. diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests.java index 2e149521fd..808d9e0caf 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -235,7 +235,7 @@ public class AmqpOutboundEndpointTests { Confirm confirm = corrData.getFuture().get(10, TimeUnit.SECONDS); assertThat(confirm).isNotNull(); assertThat(confirm.isAck()).isTrue(); - assertThat(corrData.getReturnedMessage()).isNotNull(); + assertThat(corrData.getReturned()).isNotNull(); } @Test diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java index a10fcae392..10d3117a2b 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests2.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 the original author or authors. + * Copyright 2019-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class AmqpOutboundEndpointTests2 { .setHeader(AmqpHeaders.PUBLISH_CONFIRM_CORRELATION, corr) .build()); assertThat(corr.getFuture().get(10, TimeUnit.SECONDS).isAck()).isTrue(); - assertThat(corr.getReturnedMessage()).isNotNull(); + assertThat(corr.getReturned()).isNotNull(); } @Test diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java index e379917aa9..e41decb14a 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AsyncAmqpGatewayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -253,7 +253,7 @@ class AsyncAmqpGatewayTests { .setHeader(AmqpHeaders.PUBLISH_CONFIRM_CORRELATION, corr) .build()); assertThat(corr.getFuture().get(10, TimeUnit.SECONDS).isAck()).isTrue(); - assertThat(corr.getReturnedMessage()).isNotNull(); + assertThat(corr.getReturned()).isNotNull(); asyncTemplate.stop(); ccf.destroy();