Skip to content

Commit adf1661

Browse files
authored
Format (#1610)
1 parent 8845b53 commit adf1661

21 files changed

Lines changed: 340 additions & 290 deletions

docs/src/main/asciidoc/_configprops.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
|===
22
|Name | Default | Description
33

4+
|spring.cloud.aws.appconfig.dualstack-enabled | | Configure whether the AWS client should use the AWS dualstack endpoint. Note that not each AWS service supports dual-stack. For complete list check <a href="https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html">AWS services that support IPv6</a>
5+
|spring.cloud.aws.appconfig.enabled | `+++true+++` | Enables App Config integration.
6+
|spring.cloud.aws.appconfig.endpoint | | Overrides the default endpoint.
7+
|spring.cloud.aws.appconfig.region | | Overrides the default region.
8+
|spring.cloud.aws.appconfig.reload.max-wait-for-restart | `+++2s+++` | If {@link ReloadStrategy#RESTART_CONTEXT} is configured, maximum waiting time for server restart.
9+
|spring.cloud.aws.appconfig.reload.period | `+++1m+++` | Refresh period for {@link PollingAwsPropertySourceChangeDetector}.
10+
|spring.cloud.aws.appconfig.reload.strategy | | Reload strategy to run when properties change.
11+
|spring.cloud.aws.appconfig.separator | `+++#+++` |
412
|spring.cloud.aws.cloudwatch.dualstack-enabled | | Configure whether the AWS client should use the AWS dualstack endpoint. Note that not each AWS service supports dual-stack. For complete list check <a href="https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html">AWS services that support IPv6</a>
513
|spring.cloud.aws.cloudwatch.endpoint | | Overrides the default endpoint.
614
|spring.cloud.aws.cloudwatch.region | | Overrides the default region.
@@ -93,8 +101,8 @@
93101
|spring.cloud.aws.sns.enabled | `+++true+++` | Enables SNS integration.
94102
|spring.cloud.aws.sns.endpoint | | Overrides the default endpoint.
95103
|spring.cloud.aws.sns.region | | Overrides the default region.
104+
|spring.cloud.aws.sqs.convert-message-id-to-uuid | `+++true+++` | Whether to convert SQS message IDs to UUIDs. Set to {@code false} for SQS-compatible providers that return non-UUID message IDs.
96105
|spring.cloud.aws.sqs.dualstack-enabled | | Configure whether the AWS client should use the AWS dualstack endpoint. Note that not each AWS service supports dual-stack. For complete list check <a href="https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html">AWS services that support IPv6</a>
97-
|spring.cloud.aws.sqs.convert-message-id-to-uuid | `+++true+++` | Whether to convert SQS message IDs to UUIDs. Set to `false` for SQS-compatible providers that return non-UUID message IDs.
98106
|spring.cloud.aws.sqs.enabled | `+++true+++` | Enables SQS integration.
99107
|spring.cloud.aws.sqs.endpoint | | Overrides the default endpoint.
100108
|spring.cloud.aws.sqs.listener.auto-startup | | Defines whether SQS listeners will start automatically or not.

spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sns/SnsAutoConfiguration.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242
import io.awspring.cloud.sns.core.batch.executor.SequentialBatchExecutionStrategy;
4343
import io.awspring.cloud.sns.sms.SnsSmsOperations;
4444
import io.awspring.cloud.sns.sms.SnsSmsTemplate;
45-
4645
import java.util.List;
4746
import java.util.Optional;
48-
4947
import org.springframework.beans.factory.ObjectProvider;
5048
import org.springframework.boot.autoconfigure.AutoConfiguration;
5149
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -79,22 +77,22 @@
7977
* @author Mariusz Sondecki
8078
*/
8179
@AutoConfiguration
82-
@ConditionalOnClass({SnsClient.class, SnsTemplate.class})
83-
@EnableConfigurationProperties({SnsProperties.class})
84-
@AutoConfigureAfter({CredentialsProviderAutoConfiguration.class, RegionProviderAutoConfiguration.class})
80+
@ConditionalOnClass({ SnsClient.class, SnsTemplate.class })
81+
@EnableConfigurationProperties({ SnsProperties.class })
82+
@AutoConfigureAfter({ CredentialsProviderAutoConfiguration.class, RegionProviderAutoConfiguration.class })
8583
@ConditionalOnProperty(name = "spring.cloud.aws.sns.enabled", havingValue = "true", matchIfMissing = true)
8684
public class SnsAutoConfiguration {
8785

8886
@ConditionalOnMissingBean
8987
@Bean
9088
public SnsClient snsClient(SnsProperties properties, AwsClientBuilderConfigurer awsClientBuilderConfigurer,
91-
ObjectProvider<AwsConnectionDetails> connectionDetails,
92-
ObjectProvider<SnsClientCustomizer> snsClientCustomizers,
93-
ObjectProvider<AwsSyncClientCustomizer> awsSyncClientCustomizers) {
89+
ObjectProvider<AwsConnectionDetails> connectionDetails,
90+
ObjectProvider<SnsClientCustomizer> snsClientCustomizers,
91+
ObjectProvider<AwsSyncClientCustomizer> awsSyncClientCustomizers) {
9492
return awsClientBuilderConfigurer
95-
.configureSyncClient(SnsClient.builder(), properties, connectionDetails.getIfAvailable(),
96-
snsClientCustomizers.orderedStream(), awsSyncClientCustomizers.orderedStream())
97-
.build();
93+
.configureSyncClient(SnsClient.builder(), properties, connectionDetails.getIfAvailable(),
94+
snsClientCustomizers.orderedStream(), awsSyncClientCustomizers.orderedStream())
95+
.build();
9896
}
9997

10098
@ConditionalOnMissingBean(SnsSmsOperations.class)
@@ -103,24 +101,25 @@ public SnsSmsTemplate snsSmsTemplate(SnsClient snsClient) {
103101
return new SnsSmsTemplate(snsClient);
104102
}
105103

106-
@ConditionalOnClass({SnsAsyncClient.class, SnsAsyncTemplate.class})
104+
@ConditionalOnClass({ SnsAsyncClient.class, SnsAsyncTemplate.class })
107105
@Configuration
108106
static class SnsAsyncTemplateConfiguration {
109107

110108
@Bean
111109
@ConditionalOnMissingBean(SnsAsyncOperations.class)
112110
@ConditionalOnBean(SnsAsyncClient.class)
113-
public SnsAsyncTemplate snsAsyncTemplate(SnsAsyncClient snsAsyncClient, Optional<TopicArnResolver> topicArnResolver, SnsPublishMessageConverter snsPublishMessageConverter) {
111+
public SnsAsyncTemplate snsAsyncTemplate(SnsAsyncClient snsAsyncClient,
112+
Optional<TopicArnResolver> topicArnResolver, SnsPublishMessageConverter snsPublishMessageConverter) {
114113
return topicArnResolver.map(it -> new SnsAsyncTemplate(snsAsyncClient, it, snsPublishMessageConverter))
115-
.orElseGet(() -> new SnsAsyncTemplate(snsAsyncClient, snsPublishMessageConverter));
114+
.orElseGet(() -> new SnsAsyncTemplate(snsAsyncClient, snsPublishMessageConverter));
116115
}
117116

118117
@Bean
119118
@ConditionalOnMissingBean(SnsPublishMessageConverter.class)
120119
@ConditionalOnBean(SnsAsyncClient.class)
121120
public SnsPublishMessageConverter snsPublishMessageConverter(Optional<JsonMapper> jsonMapper) {
122121
JacksonJsonMessageConverter converter = new JacksonJsonMessageConverter(
123-
jsonMapper.orElseGet(JsonMapper::new));
122+
jsonMapper.orElseGet(JsonMapper::new));
124123
converter.setSerializedPayloadClass(String.class);
125124
return new DefaultSnsPublishMessageConverter(converter);
126125
}
@@ -132,12 +131,12 @@ static class SnsConfiguration {
132131
@ConditionalOnMissingBean(SnsOperations.class)
133132
@Bean
134133
public SnsTemplate snsTemplate(SnsClient snsClient, Optional<JsonMapper> jsonMapper,
135-
Optional<TopicArnResolver> topicArnResolver, ObjectProvider<ChannelInterceptor> interceptors) {
134+
Optional<TopicArnResolver> topicArnResolver, ObjectProvider<ChannelInterceptor> interceptors) {
136135
JacksonJsonMessageConverter converter = new JacksonJsonMessageConverter(
137-
jsonMapper.orElseGet(JsonMapper::new));
136+
jsonMapper.orElseGet(JsonMapper::new));
138137
converter.setSerializedPayloadClass(String.class);
139138
SnsTemplate snsTemplate = topicArnResolver.map(it -> new SnsTemplate(snsClient, it, converter))
140-
.orElseGet(() -> new SnsTemplate(snsClient, converter));
139+
.orElseGet(() -> new SnsTemplate(snsClient, converter));
141140
interceptors.forEach(snsTemplate::addChannelInterceptor);
142141

143142
return snsTemplate;
@@ -151,12 +150,12 @@ static class LegacyJackson2Configuration {
151150
@ConditionalOnMissingBean(SnsOperations.class)
152151
@Bean
153152
public SnsTemplate snsTemplate(SnsClient snsClient, Optional<ObjectMapper> objectMapper,
154-
Optional<TopicArnResolver> topicArnResolver, ObjectProvider<ChannelInterceptor> interceptors) {
153+
Optional<TopicArnResolver> topicArnResolver, ObjectProvider<ChannelInterceptor> interceptors) {
155154
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
156155
converter.setSerializedPayloadClass(String.class);
157156
objectMapper.ifPresent(converter::setObjectMapper);
158157
SnsTemplate snsTemplate = topicArnResolver.map(it -> new SnsTemplate(snsClient, it, converter))
159-
.orElseGet(() -> new SnsTemplate(snsClient, converter));
158+
.orElseGet(() -> new SnsTemplate(snsClient, converter));
160159
interceptors.forEach(snsTemplate::addChannelInterceptor);
161160

162161
return snsTemplate;
@@ -204,7 +203,8 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)
204203
resolvers.add(getNotificationHandlerMethodArgumentResolver(snsClient));
205204
}
206205
};
207-
} else if (JacksonPresent.isJackson2Present()) {
206+
}
207+
else if (JacksonPresent.isJackson2Present()) {
208208
return new WebMvcConfigurer() {
209209
@Override
210210
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
@@ -213,7 +213,7 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)
213213
};
214214
}
215215
throw new IllegalStateException(
216-
"SnsWebMvc integration requires a Jackson 2 or Jackson 3 library on the classpath");
216+
"SnsWebMvc integration requires a Jackson 2 or Jackson 3 library on the classpath");
217217
}
218218
}
219219

spring-cloud-aws-autoconfigure/src/test/java/io/awspring/cloud/autoconfigure/sns/SnsAutoConfigurationTest.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525
import io.awspring.cloud.sns.core.SnsOperations;
2626
import io.awspring.cloud.sns.core.SnsTemplate;
2727
import io.awspring.cloud.sns.core.TopicArnResolver;
28+
import io.awspring.cloud.sns.core.async.SnsAsyncTemplate;
2829
import io.awspring.cloud.sns.core.batch.SnsBatchTemplate;
2930
import io.awspring.cloud.sns.core.batch.converter.SnsMessageConverter;
3031
import io.awspring.cloud.sns.core.batch.executor.BatchExecutionStrategy;
31-
import io.awspring.cloud.sns.core.async.SnsAsyncTemplate;
3232
import io.awspring.cloud.sns.sms.SnsSmsOperations;
3333
import io.awspring.cloud.sns.sms.SnsSmsTemplate;
34-
3534
import java.net.URI;
36-
37-
3835
import org.junit.jupiter.api.Nested;
3936
import org.junit.jupiter.api.Test;
4037
import org.springframework.boot.ApplicationRunner;
@@ -58,15 +55,15 @@
5855
class SnsAutoConfigurationTest {
5956

6057
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
61-
.withPropertyValues("spring.cloud.aws.region.static:eu-west-1")
62-
.withConfiguration(AutoConfigurations.of(RegionProviderAutoConfiguration.class,
63-
CredentialsProviderAutoConfiguration.class, SnsAutoConfiguration.class,
64-
AwsAutoConfiguration.class));
58+
.withPropertyValues("spring.cloud.aws.region.static:eu-west-1")
59+
.withConfiguration(AutoConfigurations.of(RegionProviderAutoConfiguration.class,
60+
CredentialsProviderAutoConfiguration.class, SnsAutoConfiguration.class,
61+
AwsAutoConfiguration.class));
6562

6663
@Test
6764
void snsAutoConfigurationIsDisabled() {
6865
this.contextRunner.withPropertyValues("spring.cloud.aws.sns.enabled:false")
69-
.run(context -> assertThat(context).doesNotHaveBean(SnsClient.class));
66+
.run(context -> assertThat(context).doesNotHaveBean(SnsClient.class));
7067
}
7168

7269
@Test
@@ -98,7 +95,7 @@ void withCustomEndpoint() {
9895
@Test
9996
void customTopicArnResolverCanBeConfigured() {
10097
this.contextRunner.withUserConfiguration(CustomTopicArnResolverConfiguration.class)
101-
.run(context -> assertThat(context).hasSingleBean(CustomTopicArnResolver.class));
98+
.run(context -> assertThat(context).hasSingleBean(CustomTopicArnResolver.class));
10299
}
103100

104101
@Test
@@ -132,7 +129,7 @@ void bothTemplatesAndOperationsAreInjectable() {
132129
@Test
133130
void customChannelInterceptorCanBeConfigured() {
134131
this.contextRunner.withUserConfiguration(CustomChannelInterceptorConfiguration.class)
135-
.run(context -> assertThat(context).hasSingleBean(CustomChannelInterceptor.class));
132+
.run(context -> assertThat(context).hasSingleBean(CustomChannelInterceptor.class));
136133
}
137134

138135
@Nested
@@ -159,14 +156,14 @@ void snsAsyncTemplateIsCreatedWhenSnsAsyncClientIsPresent() {
159156

160157
@Test
161158
void bothAsyncTemplatesAndOperationsAreInjectable() {
162-
contextRunner.withUserConfiguration(SnsAsyncClientConfiguration.class, InjectingAsyncTemplatesConfiguration.class).run(context -> {
163-
assertThat(context.isRunning()).isTrue();
164-
assertThat(context).hasSingleBean(SnsAsyncTemplate.class);
165-
});
159+
contextRunner.withUserConfiguration(SnsAsyncClientConfiguration.class,
160+
InjectingAsyncTemplatesConfiguration.class).run(context -> {
161+
assertThat(context.isRunning()).isTrue();
162+
assertThat(context).hasSingleBean(SnsAsyncTemplate.class);
163+
});
166164
}
167165
}
168166

169-
170167
@Configuration(proxyBeanMethods = false)
171168
static class CustomTopicArnResolverConfiguration {
172169

spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/SnsHeaders.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.awspring.cloud.sns.integration.LegacyJackson2SnsInboundChannelAdapter;
2020
import io.awspring.cloud.sns.integration.SnsInboundChannelAdapter;
2121
import org.springframework.messaging.Message;
22-
import software.amazon.awssdk.services.sns.model.PublishBatchRequestEntry;
2322
import software.amazon.awssdk.services.sns.model.PublishRequest;
2423
import software.amazon.awssdk.services.sns.model.PublishResponse;
2524

spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/async/DefaultSnsPublishMessageConverter.java

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1+
/*
2+
* Copyright 2013-2026 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.awspring.cloud.sns.core.async;
217

18+
import static io.awspring.cloud.sns.core.SnsHeaders.MESSAGE_DEDUPLICATION_ID_HEADER;
19+
import static io.awspring.cloud.sns.core.SnsHeaders.MESSAGE_GROUP_ID_HEADER;
20+
import static io.awspring.cloud.sns.core.SnsHeaders.NOTIFICATION_SUBJECT_HEADER;
21+
322
import io.awspring.cloud.sns.core.SnsHeaderConverterUtil;
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
import java.util.Map;
26+
import java.util.Optional;
427
import org.jspecify.annotations.Nullable;
528
import org.springframework.messaging.Message;
629
import org.springframework.messaging.converter.CompositeMessageConverter;
@@ -11,23 +34,14 @@
1134
import software.amazon.awssdk.services.sns.model.MessageAttributeValue;
1235
import software.amazon.awssdk.services.sns.model.PublishRequest;
1336

14-
import java.util.ArrayList;
15-
import java.util.List;
16-
import java.util.Map;
17-
import java.util.Optional;
18-
19-
import static io.awspring.cloud.sns.core.SnsHeaders.MESSAGE_DEDUPLICATION_ID_HEADER;
20-
import static io.awspring.cloud.sns.core.SnsHeaders.MESSAGE_GROUP_ID_HEADER;
21-
import static io.awspring.cloud.sns.core.SnsHeaders.NOTIFICATION_SUBJECT_HEADER;
22-
2337
/**
2438
* Default implementation of {@link SnsPublishMessageConverter}.
2539
*
2640
* @author Matej Nedic
2741
* @since 4.1.0
2842
*/
2943
public class DefaultSnsPublishMessageConverter implements SnsPublishMessageConverter {
30-
44+
3145
private final MessageConverter messageConverter;
3246

3347
public DefaultSnsPublishMessageConverter() {
@@ -44,13 +58,11 @@ public <T> PublishRequestMessagePair<T> convert(Message<T> originalMessage) {
4458

4559
PublishRequest.Builder publishRequest = PublishRequest.builder();
4660
populateHeaders(publishRequest, originalMessage);
47-
48-
Message<?> convertedMessage = messageConverter.toMessage(
49-
originalMessage.getPayload(),
50-
originalMessage.getHeaders()
51-
);
61+
62+
Message<?> convertedMessage = messageConverter.toMessage(originalMessage.getPayload(),
63+
originalMessage.getHeaders());
5264
publishRequest.message(convertedMessage.getPayload().toString());
53-
65+
5466
return new PublishRequestMessagePair<>(publishRequest.build(), originalMessage);
5567
}
5668

@@ -59,11 +71,8 @@ public <T> PublishRequestMessagePair<T> convert(T payload, Map<String, Object> h
5971
Assert.notNull(payload, "payload cannot be null");
6072
Assert.notNull(headers, "headers cannot be null");
6173

62-
Message<T> originalMessage = MessageBuilder
63-
.withPayload(payload)
64-
.copyHeaders(headers)
65-
.build();
66-
74+
Message<T> originalMessage = MessageBuilder.withPayload(payload).copyHeaders(headers).build();
75+
6776
return convert(originalMessage);
6877
}
6978

@@ -74,16 +83,15 @@ private <T> void populateHeaders(PublishRequest.Builder publishRequest, Message<
7483
}
7584

7685
Optional.ofNullable(message.getHeaders().get(NOTIFICATION_SUBJECT_HEADER, String.class))
77-
.ifPresent(publishRequest::subject);
86+
.ifPresent(publishRequest::subject);
7887

7988
Optional.ofNullable(message.getHeaders().get(MESSAGE_GROUP_ID_HEADER, String.class))
80-
.ifPresent(publishRequest::messageGroupId);
81-
89+
.ifPresent(publishRequest::messageGroupId);
90+
8291
Optional.ofNullable(message.getHeaders().get(MESSAGE_DEDUPLICATION_ID_HEADER, String.class))
83-
.ifPresent(publishRequest::messageDeduplicationId);
92+
.ifPresent(publishRequest::messageDeduplicationId);
8493
}
8594

86-
8795
private static CompositeMessageConverter initMessageConverter(@Nullable MessageConverter messageConverter) {
8896
List<MessageConverter> converters = new ArrayList<>();
8997

spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/async/PublishMessageResult.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2013-2026 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.awspring.cloud.sns.core.async;
217

318
import org.jspecify.annotations.Nullable;

spring-cloud-aws-sns/src/main/java/io/awspring/cloud/sns/core/async/PublishRequestMessagePair.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2013-2026 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.awspring.cloud.sns.core.async;
217

318
import org.springframework.messaging.Message;

0 commit comments

Comments
 (0)