-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Upcoming End-of-Support
- I acknowledge the upcoming end-of-support for AWS SDK for Java v1 was announced, and migration to AWS SDK for Java v2 is recommended.
Describe the bug
Summary
We are encountering a ConcurrentModificationException
when upgrading from AWS SDK v2.25.51 to later versions (confirmed as of v2.31.77) in applications that use SQS or S3 clients. This issue does not occur in v2.25.51 but starts appearing in subsequent versions.
Context
We are in the process of upgrading the minor versions of all our applications. However, applications using DynamoDB along with SQS or S3 begin throwing this exception when attempting to instantiate the SQS or S3 clients.
Our applications are Spring Boot-based and authenticate with AWS via EC2 instance roles (IAM roles with appropriate permissions via Allow rules). The exception occurs during the application startup phase, indicating a build-time or initialization-time failure.
If it helps, we are using Spring Boot version 3.5.3 and Java 22.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Applications using the latest AWS SDK for Java v2 should start successfully when instantiating SQS or S3 clients, without throwing runtime exceptions. Specifically, upgrading from v2.25.51 to a later minor version (e.g., v2.31.77) should not introduce any errors during application startup or client initialisation.
Current Behavior
After upgrading the AWS SDK for Java from v2.25.51 to v2.31.77 (or other versions post-2.25.51), applications that use SQS or S3 clients begin throwing a ConcurrentModificationException during startup. This exception occurs during client instantiation and prevents the application from starting. The issue appears only in applications that use SQS or S3 (not DynamoDB alone) and are running in Spring Boot (v3.5.3) with Java 22 on EC2 instances using IAM instance roles for authentication.
Reproduction Steps
I was unable to create a fully-runnable MRE due to the way our architecture works, but I tried my best to hopefully provide enough context to understand the issue.
Should this be too unclear, please let me know and I will try to provide a more detailed example.
The following is a simplified POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>foo-bar</artifactId>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.3</version>
</parent>
<properties>
<java.version>22</java.version>
<log4j2.version>2.24.3</log4j2.version>
<!-- Using newer versions causes java.util.ConcurrentModificationException -->
<awssdk.version>2.25.51</awssdk.version>
</properties>
<repositories>
<repository>
<id>JCenter</id>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>io.github.boostchicken</groupId>
<artifactId>spring-data-dynamodb</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
<version>${awssdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>${awssdk.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The following is the Java code used to instantiate the S3 client:
@Service
public class S3Service {
private final S3Client s3Client;
public S3Service() {
S3Configuration config = S3Configuration.builder()
.pathStyleAccessEnabled(true)
.build();
this.s3Client = S3Client.builder()
.serviceConfiguration(config)
.endpointOverride(null)
.region(Region.EU_WEST_1)
.build();
}
}
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
22
JDK version used
openjdk version "22.0.2" 2024-07-16
Operating System and version
Mac OS 15.5 (24F74)