From cbb1dd440c5bac4ad9bbe8757f7955213d0fa077 Mon Sep 17 00:00:00 2001
From: Ran Vaknin <50976344+RanVaknin@users.noreply.github.com>
Date: Fri, 5 Sep 2025 09:41:57 -0700
Subject: [PATCH 01/20] Add utils-lite package (#6395)
Add utils-lite package
---
.brazil.json | 1 +
bom/pom.xml | 5 ++
pom.xml | 2 +
test/architecture-tests/pom.xml | 5 ++
.../archtests/UtilsLitePackageTest.java | 43 ++++++++++
test/tests-coverage-reporting/pom.xml | 5 ++
utils-lite/pom.xml | 79 +++++++++++++++++++
.../utilslite/SdkInternalThreadLocal.java | 55 +++++++++++++
.../awssdk/utilslite/ThreadStorageTest.java | 70 ++++++++++++++++
9 files changed, 265 insertions(+)
create mode 100644 test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/UtilsLitePackageTest.java
create mode 100644 utils-lite/pom.xml
create mode 100644 utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
create mode 100644 utils-lite/src/test/java/software/amazon/awssdk/utilslite/ThreadStorageTest.java
diff --git a/.brazil.json b/.brazil.json
index 7d240cb9bf5c..362888889178 100644
--- a/.brazil.json
+++ b/.brazil.json
@@ -32,6 +32,7 @@
"s3-transfer-manager": { "packageName": "AwsJavaSdk-S3-TransferManager" },
"s3-event-notifications": { "packageName": "AwsJavaSdk-S3-EventNotifications" },
"sdk-core": { "packageName": "AwsJavaSdk-Core" },
+ "utils-lite": { "packageName": "AwsJavaSdk-UtilsLite" },
"url-connection-client": { "packageName": "AwsJavaSdk-HttpClient-UrlConnectionClient" },
"utils": { "packageName": "AwsJavaSdk-Core-Utils" },
"imds": { "packageName": "AwsJavaSdk-Imds" },
diff --git a/bom/pom.xml b/bom/pom.xml
index 18f4e532fb89..2976999b5add 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -212,6 +212,11 @@
utils
${awsjavasdk.version}
+
+ software.amazon.awssdk
+ utils-lite
+ ${awsjavasdk.version}
+
software.amazon.awssdk
cloudwatch-metric-publisher
diff --git a/pom.xml b/pom.xml
index 0829651b50fc..86e4f37b0ff4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,7 @@
metric-publishers
release-scripts
utils
+ utils-lite
codegen-lite
codegen-lite-maven-plugin
archetypes
@@ -664,6 +665,7 @@
cloudwatch-metric-publisher
emf-metric-logging-publisher
utils
+ utils-lite
imds
retries
retries-spi
diff --git a/test/architecture-tests/pom.xml b/test/architecture-tests/pom.xml
index 4d4483104df0..9e30c195ac6c 100644
--- a/test/architecture-tests/pom.xml
+++ b/test/architecture-tests/pom.xml
@@ -61,6 +61,11 @@
software.amazon.awssdk
${awsjavasdk.version}
+
+ utils-lite
+ software.amazon.awssdk
+ ${awsjavasdk.version}
+
s3
software.amazon.awssdk
diff --git a/test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/UtilsLitePackageTest.java b/test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/UtilsLitePackageTest.java
new file mode 100644
index 000000000000..437094a4c58f
--- /dev/null
+++ b/test/architecture-tests/src/test/java/software/amazon/awssdk/archtests/UtilsLitePackageTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.archtests;
+
+import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
+
+import com.tngtech.archunit.core.domain.JavaClasses;
+import com.tngtech.archunit.core.importer.ClassFileImporter;
+import com.tngtech.archunit.lang.ArchRule;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Architecture tests for the utils-lite package to ensure it only contains allowed classes.
+ */
+public class UtilsLitePackageTest {
+
+ private static final JavaClasses CLASSES = new ClassFileImporter()
+ .importPackages("software.amazon.awssdk.utilslite");
+
+ @Test
+ public void utilsLitePackage_shouldOnlyContainAllowedClasses() {
+ ArchRule rule = classes()
+ .that().resideInAPackage("software.amazon.awssdk.utilslite")
+ .should().haveNameMatching(".*\\.(SdkInternalThreadLocal|SdkInternalThreadLocalTest)")
+ .allowEmptyShould(true)
+ .because("utils-lite package should only contain SdkInternalThreadLocal and its test");
+
+ rule.check(CLASSES);
+ }
+}
\ No newline at end of file
diff --git a/test/tests-coverage-reporting/pom.xml b/test/tests-coverage-reporting/pom.xml
index 891b0bb3f1ff..c3af80154ff5 100644
--- a/test/tests-coverage-reporting/pom.xml
+++ b/test/tests-coverage-reporting/pom.xml
@@ -326,6 +326,11 @@
http-client-spi
${awsjavasdk.version}
+
+ software.amazon.awssdk
+ utils-lite
+ ${awsjavasdk.version}
+
diff --git a/utils-lite/pom.xml b/utils-lite/pom.xml
new file mode 100644
index 000000000000..9642803ccd58
--- /dev/null
+++ b/utils-lite/pom.xml
@@ -0,0 +1,79 @@
+
+
+
+
+ 4.0.0
+
+ software.amazon.awssdk
+ aws-sdk-java-pom
+ 2.33.3-SNAPSHOT
+
+ utils-lite
+ AWS Java SDK :: Utils Lite
+
+ A package providing minimal external utils.
+
+ https://aws.amazon.com/sdkforjava
+
+
+
+
+ software.amazon.awssdk
+ bom-internal
+ ${project.version}
+ pom
+ import
+
+
+
+
+
+
+ software.amazon.awssdk
+ annotations
+ ${awsjavasdk.version}
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ software.amazon.awssdk.utilslite
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java b/utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
new file mode 100644
index 000000000000..34f3b5c9df30
--- /dev/null
+++ b/utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.utilslite;
+
+import java.util.HashMap;
+import java.util.Map;
+import software.amazon.awssdk.annotations.SdkProtectedApi;
+
+/**
+ * Utility for thread-local context storage.
+ */
+@SdkProtectedApi
+public final class SdkInternalThreadLocal {
+ private static final ThreadLocal