Repository navigation
Description
Type: Bug
Component: SQS
Describe the bug
SqsAutoConfiguration.configureProperties() maps SqsProperties.Listener's
maxConcurrentMessages, maxMessagesPerPoll, pollTimeout, maxDelayBetweenPolls,
and autoStartup unconditionally:
private void configureProperties(SqsContainerOptionsBuilder options) {
PropertyMapper mapper = PropertyMapper.get();
mapper.from(this.sqsProperties.getQueueNotFoundStrategy()).to(options::queueNotFoundStrategy);
mapper.from(this.sqsProperties.getListener().getMaxConcurrentMessages()).to(options::maxConcurrentMessages);
...All five Listener fields are @Nullable with no default, so an application that doesn't
explicitly set any of them (reasonable, since they all have sensible built-in defaults in
AbstractContainerOptions.Builder) gets a crash on every context startup:
- a
NullPointerExceptionfrom unboxingnullinto the primitiveint/booleansetters
(maxConcurrentMessages,maxMessagesPerPoll,autoStartup), or - an
IllegalArgumentExceptionfrom theAssert.notNullguards inside
AbstractContainerOptions.Builder(pollTimeout,maxDelayBetweenPolls)
-- whichever field the mapper reaches first.
This is a regression from 3.4.2, whose equivalent method guarded the whole block:
private void configureProperties(SqsContainerOptionsBuilder options) {
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
...That .alwaysApplyingWhenNonNull() call is missing in every 4.x release checked directly
against the Maven Central sources jars: 4.0.0, 4.0.1, 4.0.2, 4.1.0, 4.1.1 (latest).
Observed stack trace (with spring.cloud.aws.sqs.queue-not-found-strategy set, everything
else left at its default):
Caused by: java.lang.NullPointerException
at org.springframework.boot.context.properties.PropertyMapper$Source.to(PropertyMapper.java:294)
at io.awspring.cloud.autoconfigure.sqs.SqsAutoConfiguration.configureProperties(SqsAutoConfiguration.java:214)
at io.awspring.cloud.sqs.config.AbstractMessageListenerContainerFactory.configure(AbstractMessageListenerContainerFactory.java:174)
at io.awspring.cloud.autoconfigure.sqs.SqsAutoConfiguration.defaultSqsListenerContainerFactory(SqsAutoConfiguration.java:192)
Expected: unset listener properties should fall back to AbstractContainerOptions.Builder's
own defaults, as they did in 3.x, rather than crashing context startup.
Suggested fix: restore PropertyMapper.get().alwaysApplyingWhenNonNull() (or add
.whenNonNull() per mapping) in SqsAutoConfiguration.configureProperties().
Versions:
- spring-cloud-aws-dependencies: 4.1.1 (also present in 4.0.0-4.1.0)
- Spring Boot: 3.5.16
- Java: 21 / 25
Sample
Minimal Spring Boot app that reproduces this on context startup. Only dependency beyond
spring-boot-starter is spring-cloud-aws-starter-sqs (version managed by the
spring-cloud-aws-dependencies:4.1.1 BOM); no spring.cloud.aws.sqs.listener.*
properties are set.
pom.xml (relevant sections):
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>4.1.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-starter-sqs</artifactId>
</dependency>
</dependencies>application.properties:
spring.cloud.aws.region.static=us-east-1
spring.cloud.aws.sqs.queue-not-found-strategy=failTest (the mocked SqsAsyncClient bean only exists to isolate this from real network/event-loop
setup, which is unrelated to the bug):
@SpringBootTest
class ReproApplicationTests {
@TestConfiguration
static class MockSqsClientConfig {
@Bean
SqsAsyncClient sqsAsyncClient() {
return mock(SqsAsyncClient.class);
}
}
@Test
void contextLoads() {
}
}Running this test throws the NullPointerException above immediately on context startup.
Activity
gibkim commentedon Oct 3, 2026
I think this comes from running 4.1.1 on Spring Boot 3.5. The README says 3.4.x is the last Spring Cloud AWS line compatible with Boot 3.5.x, and 4.x targets Boot 4.
In Boot 4,
PropertyMapperskipsnullsources by default (class Javadoc: "By defaultnullvalues and anyNullPointerExceptionthrown from the supplier are filtered and will not be applied to consumers";Source.always(), added in 4.0.0, opts out). That is whyalwaysApplyingWhenNonNull()is no longer needed in 4.x. On Boot 3.5 the same code maps thenullvalues and fails.I ran the reproducer from the description (mocked
SqsAsyncClient, onlyqueue-not-found-strategyset, nolistener.*properties):SqsMessageListenerContainerFactorycreatedNullPointerExceptionatPropertyMapper.java:294, as reportedSo on a supported combination this doesn't fail. If 4.x is meant to work on Boot 3.5 too, the fix suggested above would be needed; otherwise upgrading to Boot 4 or staying on 3.4.x avoids it.
MatejNedic commentedon Oct 14, 2026
Hey @pasaroll ,
Spring Boot 3.5.16 shouldn't be used with Spring Cloud AWS 4.1.1.
Spring Cloud AWS 4.x.x is only compatible with Spring Boot version 4.x.x and above. Please check Spring Cloud AWS version support.
Please use Spring Cloud AWS version 3.4.2 with Spring Boot 3.5.16.