Skip to content

Commit 0203652

Browse files
committed
Move Spring dependencies to SNAPSHOT
* Fix `AbstractAmqpChannel` to add messaging packages as allowed for deserialization * Some code style clean up in the `AbstractSubscribableAmqpChannel` * Disable Kraft (default) for Kafka tests since they are not reliable(perhaps only on Windows)
1 parent 49cd14c commit 0203652

File tree

6 files changed

+54
-25
lines changed

6 files changed

+54
-25
lines changed

Diff for: build.gradle

+8-8
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ ext {
9090
lettuceVersion = '6.2.6.RELEASE'
9191
log4jVersion = '2.20.0'
9292
mailVersion = '2.0.2'
93-
micrometerTracingVersion = '1.2.0-M3'
94-
micrometerVersion = '1.12.0-M3'
93+
micrometerTracingVersion = '1.2.0-SNAPSHOT'
94+
micrometerVersion = '1.12.0-SNAPSHOT'
9595
mockitoVersion = '5.5.0'
9696
mongoDriverVersion = '4.10.2'
9797
mysqlVersion = '8.0.33'
@@ -100,19 +100,19 @@ ext {
100100
postgresVersion = '42.6.0'
101101
protobufVersion = '3.24.3'
102102
r2dbch2Version = '1.0.0.RELEASE'
103-
reactorVersion = '2023.0.0-M3'
103+
reactorVersion = '2023.0.0-SNAPSHOT'
104104
resilience4jVersion = '2.1.0'
105105
romeToolsVersion = '2.1.0'
106106
rsocketVersion = '1.1.4'
107107
servletApiVersion = '6.0.0'
108108
smackVersion = '4.4.6'
109-
springAmqpVersion = '3.1.0-M1'
110-
springDataVersion = '2023.1.0-M3'
109+
springAmqpVersion = '3.1.0-SNAPSHOT'
110+
springDataVersion = '2023.1.0-SNAPSHOT'
111111
springGraphqlVersion = '1.2.3'
112-
springKafkaVersion = '3.1.0-M1'
112+
springKafkaVersion = '3.1.0-SNAPSHOT'
113113
springRetryVersion = '2.0.3'
114-
springSecurityVersion = '6.2.0-M3'
115-
springVersion = '6.1.0-M5'
114+
springSecurityVersion = '6.2.0-SNAPSHOT'
115+
springVersion = '6.1.0-SNAPSHOT'
116116
springWsVersion = '4.0.6'
117117
testcontainersVersion = '1.19.0'
118118
tomcatVersion = '10.1.13'

Diff for: spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractAmqpChannel.java

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,11 +23,20 @@
2323
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
2424
import org.springframework.amqp.rabbit.connection.ConnectionListener;
2525
import org.springframework.amqp.rabbit.core.RabbitTemplate;
26+
import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter;
27+
import org.springframework.amqp.support.converter.MessageConverter;
2628
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
2729
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
2830
import org.springframework.integration.amqp.support.MappingUtils;
2931
import org.springframework.integration.channel.AbstractMessageChannel;
32+
import org.springframework.integration.history.MessageHistory;
33+
import org.springframework.integration.message.AdviceMessage;
34+
import org.springframework.integration.support.MutableMessage;
35+
import org.springframework.integration.support.MutableMessageHeaders;
3036
import org.springframework.messaging.Message;
37+
import org.springframework.messaging.MessageHeaders;
38+
import org.springframework.messaging.support.ErrorMessage;
39+
import org.springframework.messaging.support.GenericMessage;
3140
import org.springframework.util.Assert;
3241

3342
/**
@@ -87,6 +96,19 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel impleme
8796
this.amqpTemplate = amqpTemplate;
8897
if (amqpTemplate instanceof RabbitTemplate) {
8998
this.rabbitTemplate = (RabbitTemplate) amqpTemplate;
99+
MessageConverter converter = this.rabbitTemplate.getMessageConverter();
100+
if (converter instanceof AllowedListDeserializingMessageConverter allowedListMessageConverter) {
101+
allowedListMessageConverter.addAllowedListPatterns(
102+
"java.util*",
103+
"java.lang*",
104+
GenericMessage.class.getName(),
105+
ErrorMessage.class.getName(),
106+
AdviceMessage.class.getName(),
107+
MutableMessage.class.getName(),
108+
MessageHeaders.class.getName(),
109+
MutableMessageHeaders.class.getName(),
110+
MessageHistory.class.getName());
111+
}
90112
}
91113
else {
92114
this.rabbitTemplate = null;
@@ -143,7 +165,7 @@ protected boolean isExtractPayload() {
143165

144166
/**
145167
* When mapping headers for the outbound message, determine whether the headers are
146-
* mapped before the message is converted, or afterwards. This only affects headers
168+
* mapped before the message is converted, or afterward. This only affects headers
147169
* that might be added by the message converter. When false, the converter's headers
148170
* win; when true, any headers added by the converter will be overridden (if the
149171
* source message has a header that maps to those headers). You might wish to set this
@@ -242,10 +264,6 @@ public void onCreate(Connection connection) {
242264
doDeclares();
243265
}
244266

245-
@Override
246-
public void onClose(Connection connection) {
247-
}
248-
249267
protected abstract void doDeclares();
250268

251269
}

Diff for: spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
2424
import org.springframework.amqp.AmqpConnectException;
2525
import org.springframework.amqp.core.AmqpTemplate;
2626
import org.springframework.amqp.core.MessageListener;
27+
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
2728
import org.springframework.amqp.rabbit.core.RabbitAdmin;
2829
import org.springframework.amqp.rabbit.core.RabbitTemplate;
2930
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
@@ -77,6 +78,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
7778
*/
7879
protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
7980
AmqpTemplate amqpTemplate) {
81+
8082
this(channelName, container, amqpTemplate, false);
8183
}
8284

@@ -93,6 +95,7 @@ protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageLis
9395
*/
9496
protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageListenerContainer container,
9597
AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) {
98+
9699
this(channelName, container, amqpTemplate, false, outboundMapper, inboundMapper);
97100
}
98101

@@ -108,6 +111,7 @@ protected AbstractSubscribableAmqpChannel(String channelName, AbstractMessageLis
108111
protected AbstractSubscribableAmqpChannel(String channelName,
109112
AbstractMessageListenerContainer container,
110113
AmqpTemplate amqpTemplate, boolean isPubSub) {
114+
111115
this(channelName, container, amqpTemplate, isPubSub,
112116
DefaultAmqpHeaderMapper.outboundMapper(), DefaultAmqpHeaderMapper.inboundMapper());
113117
}
@@ -128,14 +132,16 @@ protected AbstractSubscribableAmqpChannel(String channelName,
128132
AbstractMessageListenerContainer container,
129133
AmqpTemplate amqpTemplate, boolean isPubSub,
130134
AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) {
135+
131136
super(amqpTemplate, outboundMapper, inboundMapper);
132137
Assert.notNull(container, "container must not be null");
133138
Assert.hasText(channelName, "channel name must not be empty");
134139
this.channelName = channelName;
135140
this.container = container;
136141
this.isPubSub = isPubSub;
137-
setConnectionFactory(container.getConnectionFactory());
138-
setAdmin(new RabbitAdmin(getConnectionFactory()));
142+
ConnectionFactory connectionFactory = container.getConnectionFactory();
143+
setConnectionFactory(connectionFactory);
144+
setAdmin(new RabbitAdmin(connectionFactory));
139145
}
140146

141147
/**
@@ -173,11 +179,13 @@ public void onInit() {
173179
setMaxSubscribers(this.maxSubscribers);
174180
String queue = obtainQueueName(this.channelName);
175181
this.container.setQueueNames(queue);
176-
MessageConverter converter = (this.getAmqpTemplate() instanceof RabbitTemplate)
177-
? ((RabbitTemplate) this.getAmqpTemplate()).getMessageConverter()
182+
MessageConverter converter =
183+
(getAmqpTemplate() instanceof RabbitTemplate rabbitTemplate)
184+
? rabbitTemplate.getMessageConverter()
178185
: new SimpleMessageConverter();
179-
MessageListener listener = new DispatchingMessageListener(converter,
180-
this.dispatcher, this, this.isPubSub,
186+
187+
MessageListener listener =
188+
new DispatchingMessageListener(converter, this.dispatcher, this, this.isPubSub,
181189
getMessageBuilderFactory(), getInboundHeaderMapper());
182190
this.container.setMessageListener(listener);
183191
if (!this.container.isActive()) {
@@ -256,7 +264,7 @@ public void destroy() {
256264

257265
private static final class DispatchingMessageListener implements MessageListener {
258266

259-
private final Log logger = LogFactory.getLog(this.getClass());
267+
private final Log logger = LogFactory.getLog(DispatchingMessageListener.class);
260268

261269
private final MessageDispatcher dispatcher;
262270

@@ -273,6 +281,7 @@ private static final class DispatchingMessageListener implements MessageListener
273281
private DispatchingMessageListener(MessageConverter converter,
274282
MessageDispatcher dispatcher, AbstractSubscribableAmqpChannel channel, boolean isPubSub,
275283
MessageBuilderFactory messageBuilderFactory, AmqpHeaderMapper inboundHeaderMapper) {
284+
276285
Assert.notNull(converter, "MessageConverter must not be null");
277286
Assert.notNull(dispatcher, "MessageDispatcher must not be null");
278287
this.converter = converter;
@@ -308,7 +317,7 @@ public void onMessage(org.springframework.amqp.core.Message message) {
308317
}
309318
}
310319

311-
protected Message<Object> buildMessage(org.springframework.amqp.core.Message message, Object converted) {
320+
private Message<Object> buildMessage(org.springframework.amqp.core.Message message, Object converted) {
312321
AbstractIntegrationMessageBuilder<Object> messageBuilder =
313322
this.messageBuilderFactory.withPayload(converted);
314323
if (this.channel.isExtractPayload()) {

Diff for: spring-integration-kafka/src/test/java/org/springframework/integration/kafka/inbound/InboundGatewayTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
*
7777
*/
7878
@EmbeddedKafka(controlledShutdown = true,
79+
kraft = false,
7980
topics = {InboundGatewayTests.topic1,
8081
InboundGatewayTests.topic2,
8182
InboundGatewayTests.topic3,

Diff for: spring-integration-kafka/src/test/java/org/springframework/integration/kafka/outbound/KafkaProducerMessageHandlerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import org.springframework.kafka.support.SendResult;
7777
import org.springframework.kafka.support.converter.RecordMessageConverter;
7878
import org.springframework.kafka.test.EmbeddedKafkaBroker;
79+
import org.springframework.kafka.test.EmbeddedKafkaKraftBroker;
7980
import org.springframework.kafka.test.utils.KafkaTestUtils;
8081
import org.springframework.kafka.transaction.KafkaTransactionManager;
8182
import org.springframework.lang.Nullable;
@@ -139,8 +140,7 @@ class KafkaProducerMessageHandlerTests {
139140

140141
@BeforeAll
141142
static void setup() {
142-
embeddedKafka = new EmbeddedKafkaBroker(1, true,
143-
topic1, topic2, topic3, topic4, topic5, topic6);
143+
embeddedKafka = new EmbeddedKafkaKraftBroker(1, 2, topic1, topic2, topic3, topic4, topic5, topic6);
144144
embeddedKafka.afterPropertiesSet();
145145
Map<String, Object> consumerProps = KafkaTestUtils.consumerProps("testOut", "true", embeddedKafka);
146146
consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
spring.kafka.global.embedded.enabled = true
2+
spring.kafka.embedded.kraft=false
23
spring.embedded.kafka.brokers.property=spring.global.embedded.kafka.brokers
34
spring.kafka.embedded.partitions=1

0 commit comments

Comments
 (0)