diff --git a/.github/scripts/check-linkedin-release.py b/.github/scripts/check-linkedin-release.py
new file mode 100644
index 000000000000..ca9101b1b905
--- /dev/null
+++ b/.github/scripts/check-linkedin-release.py
@@ -0,0 +1,120 @@
+"""Fail closed before building or publishing a LinkedIn SDK release."""
+
+import argparse
+import json
+import os
+import re
+import sys
+import urllib.error
+import urllib.request
+import xml.etree.ElementTree as ET
+from pathlib import Path
+
+
+NAMESPACE = {"m": "http://maven.apache.org/POM/4.0.0"}
+REPOSITORY = "https://linkedin.jfrog.io/artifactory/li-aws-sdk-java-v2"
+GITHUB_REPOSITORY = "linkedin/li-aws-sdk-java-v2"
+RELEASE_REF = "refs/heads/s3-li-2.49.1"
+
+
+def eligible_release(event, repository, ref, sha, pages):
+ if repository != GITHUB_REPOSITORY or ref != RELEASE_REF:
+ return False
+ if event == "workflow_dispatch":
+ return True
+ if event != "push":
+ return False
+ return any(
+ pull["merged_at"] is not None
+ and pull["merge_commit_sha"] == sha
+ and pull["base"]["ref"] == "s3-li-2.49.1"
+ and pull["base"]["repo"]["full_name"] == GITHUB_REPOSITORY
+ for page in pages
+ for pull in page
+ )
+
+
+def validate_pom(pom, expected):
+ if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+-li-[0-9]+\.[0-9]+", expected):
+ raise ValueError("Expected a release version such as 2.49.1-li-0.1, not a snapshot.")
+ if pom.findtext("m:version", namespaces=NAMESPACE) != expected:
+ raise ValueError("Requested version does not match the checked-out root POM.")
+ if pom.findtext("m:groupId", namespaces=NAMESPACE) != "software.amazon.awssdk":
+ raise ValueError("Unexpected Maven group.")
+ if pom.findtext("m:artifactId", namespaces=NAMESPACE) != "aws-sdk-java-pom":
+ raise ValueError("Run this check from the SDK repository root.")
+ repository = pom.find("m:distributionManagement/m:repository", NAMESPACE)
+ if repository is None:
+ raise ValueError("Missing release repository.")
+ if (
+ repository.findtext("m:id", namespaces=NAMESPACE) != "central"
+ or repository.findtext("m:url", namespaces=NAMESPACE) != REPOSITORY
+ ):
+ raise ValueError("Release destination must be the existing LinkedIn SDK JFrog repository.")
+
+
+def require_unpublished(version, opener=urllib.request.urlopen):
+ # Representative coordinates also catch common partially published releases.
+ # This is not an atomic reservation; JFrog must independently deny release overwrites.
+ for artifact in ("aws-sdk-java-pom", "bom", "s3", "netty-nio-client"):
+ url = f"{REPOSITORY}/software/amazon/awssdk/{artifact}/{version}/{artifact}-{version}.pom"
+ try:
+ with opener(url, timeout=30):
+ raise ValueError(f"{artifact}:{version} already exists. Do not overwrite or blindly retry.")
+ except urllib.error.HTTPError as error:
+ if error.code != 404:
+ raise ValueError(f"Cannot establish absence of {artifact}: HTTP {error.code}") from error
+
+
+def validate_fork_versions(path, expected, seen=None):
+ if seen is None:
+ seen = set()
+ path = path.resolve()
+ if path not in seen:
+ seen.add(path)
+ pom = ET.parse(path).getroot()
+ for node in pom.findall(".//m:version", NAMESPACE):
+ if node.text and "-li-" in node.text and node.text != expected:
+ raise ValueError(f"Inconsistent fork version {node.text} in {path}.")
+ modules = pom.findall("m:modules/m:module", NAMESPACE)
+ modules += pom.findall("m:profiles/m:profile/m:modules/m:module", NAMESPACE)
+ for module in modules:
+ validate_fork_versions(path.parent / module.text / "pom.xml", expected, seen)
+ return seen
+
+
+def prepare_release(path, expected=None, opener=urllib.request.urlopen):
+ pom = ET.parse(path).getroot()
+ version = pom.findtext("m:version", namespaces=NAMESPACE) if expected is None else expected
+ validate_pom(pom, version or "")
+ validate_fork_versions(path, version)
+ require_unpublished(version, opener)
+ return version
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ mode = parser.add_mutually_exclusive_group()
+ mode.add_argument("--select", action="store_true", help="Select manual runs and merged-PR pushes.")
+ mode.add_argument("--prepare", action="store_true", help="Validate and output the committed release version.")
+ args = parser.parse_args()
+ if args.select:
+ event = os.environ["GITHUB_EVENT_NAME"]
+ pages = json.load(sys.stdin) if event == "push" else []
+ eligible = eligible_release(
+ event, os.environ["GITHUB_REPOSITORY"], os.environ["GITHUB_REF"], os.environ["GITHUB_SHA"], pages
+ )
+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
+ output.write(f"eligible={str(eligible).lower()}\n")
+ print("Release selected." if eligible else "No matching merged release PR; publishing skipped.")
+ return
+ expected = None if args.prepare and os.environ["GITHUB_EVENT_NAME"] == "push" else os.environ["RELEASE_VERSION"]
+ version = prepare_release(Path("pom.xml"), expected)
+ if args.prepare:
+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
+ output.write(f"version={version}\n")
+ print(f"Validated unpublished LinkedIn SDK release {version}.")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.github/scripts/test_check_linkedin_release.py b/.github/scripts/test_check_linkedin_release.py
new file mode 100644
index 000000000000..c2da42e0544a
--- /dev/null
+++ b/.github/scripts/test_check_linkedin_release.py
@@ -0,0 +1,267 @@
+import copy
+import importlib.util
+import json
+import os
+import subprocess
+import sys
+import unittest
+import urllib.error
+import xml.etree.ElementTree as ET
+from pathlib import Path
+from tempfile import TemporaryDirectory
+from unittest.mock import MagicMock, patch
+
+
+SPEC = importlib.util.spec_from_file_location("release", Path(__file__).with_name("check-linkedin-release.py"))
+release = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(release)
+VERSION = "2.49.1-li-0.5"
+
+
+class ReleaseCheckTest(unittest.TestCase):
+ def pom(self):
+ return ET.fromstring(
+ ''
+ 'software.amazon.awssdkaws-sdk-java-pom'
+ f'{VERSION}'
+ 'central'
+ f'{release.REPOSITORY}'
+ ''
+ )
+
+ def test_valid_version_and_destination(self):
+ pom = self.pom()
+ pom.find("m:version", release.NAMESPACE).text = VERSION
+ release.validate_pom(pom, VERSION)
+
+ def test_rejects_invalid_or_mismatched_version(self):
+ for version in ("", "2.49.1-li-0.5-SNAPSHOT", "$(echo bad)", "2.49.1-li-0.999"):
+ with self.subTest(version=version), self.assertRaises(ValueError):
+ release.validate_pom(self.pom(), version)
+
+ def test_rejects_wrong_destination_or_identity(self):
+ for path in (
+ "m:groupId",
+ "m:artifactId",
+ "m:distributionManagement/m:repository/m:id",
+ "m:distributionManagement/m:repository/m:url",
+ ):
+ pom = self.pom()
+ pom.find("m:version", release.NAMESPACE).text = VERSION
+ pom.find(path, release.NAMESPACE).text = "wrong"
+ with self.subTest(path=path), self.assertRaises(ValueError):
+ release.validate_pom(pom, VERSION)
+
+ def test_checks_all_representative_artifacts(self):
+ opener = MagicMock(side_effect=urllib.error.HTTPError("url", 404, "missing", {}, None))
+ release.require_unpublished(VERSION, opener)
+ self.assertEqual(opener.call_count, 4)
+ for call, artifact in zip(opener.call_args_list, ("aws-sdk-java-pom", "bom", "s3", "netty-nio-client")):
+ self.assertTrue(call.args[0].endswith(f"/{artifact}/{VERSION}/{artifact}-{VERSION}.pom"))
+
+ def test_rejects_stale_fork_version_in_a_module(self):
+ with TemporaryDirectory() as directory:
+ path = Path(directory) / "pom.xml"
+ path.write_text(
+ ''
+ '2.49.1-li-0.4'
+ )
+ with self.assertRaisesRegex(ValueError, "Inconsistent fork version"):
+ release.validate_fork_versions(path, VERSION)
+ path.write_text(path.read_text().replace("2.49.1-li-0.4", VERSION))
+ release.validate_fork_versions(path, VERSION)
+
+ def test_checks_modules_and_profile_modules_not_archetype_templates(self):
+ for modules in (
+ "child",
+ "child",
+ ):
+ with self.subTest(modules=modules), TemporaryDirectory() as directory:
+ root = Path(directory)
+ (root / "pom.xml").write_text(
+ f'{modules}'
+ )
+ (root / "child").mkdir()
+ (root / "child/pom.xml").write_text(
+ ''
+ '2.49.1-li-0.4'
+ )
+ (root / "template").mkdir()
+ (root / "template/pom.xml").write_text("not an actual Maven POM")
+ with self.assertRaisesRegex(ValueError, "Inconsistent fork version"):
+ release.validate_fork_versions(root / "pom.xml", VERSION)
+ (root / "child/pom.xml").write_text((root / "child/pom.xml").read_text().replace("0.4", "0.5"))
+ release.validate_fork_versions(root / "pom.xml", VERSION)
+
+ def test_rejects_existing_or_partial_release(self):
+ opener = MagicMock()
+ opener.side_effect = [
+ urllib.error.HTTPError("url", 404, "missing", {}, None),
+ MagicMock(),
+ ]
+ with self.assertRaisesRegex(ValueError, "already exists"):
+ release.require_unpublished(VERSION, opener)
+
+ def test_auth_server_and_transport_errors_do_not_mean_absent(self):
+ for code in (401, 403, 429, 500):
+ opener = MagicMock(side_effect=urllib.error.HTTPError("url", code, "error", {}, None))
+ with self.subTest(code=code), self.assertRaises(ValueError):
+ release.require_unpublished(VERSION, opener)
+ with self.assertRaises(urllib.error.URLError):
+ release.require_unpublished(VERSION, MagicMock(side_effect=urllib.error.URLError("network failure")))
+
+ def test_selects_only_manual_runs_or_merged_release_commits(self):
+ sha = "a" * 40
+ pull = {
+ "merged_at": "2026-11-10T00:00:00Z",
+ "merge_commit_sha": sha,
+ "base": {"ref": "s3-li-2.49.1", "repo": {"full_name": release.GITHUB_REPOSITORY}},
+ }
+ self.assertTrue(
+ release.eligible_release("workflow_dispatch", release.GITHUB_REPOSITORY, release.RELEASE_REF, sha, [])
+ )
+ self.assertTrue(
+ release.eligible_release("push", release.GITHUB_REPOSITORY, release.RELEASE_REF, sha, [[], [pull]])
+ )
+ for event, repository, ref, pages in (
+ ("push", release.GITHUB_REPOSITORY, release.RELEASE_REF, []),
+ ("pull_request", release.GITHUB_REPOSITORY, release.RELEASE_REF, [[pull]]),
+ ("push", "someone/fork", release.RELEASE_REF, [[pull]]),
+ ("workflow_dispatch", release.GITHUB_REPOSITORY, "refs/heads/master", []),
+ ("push", release.GITHUB_REPOSITORY, "refs/tags/s3-li-2.49.1", [[pull]]),
+ ):
+ with self.subTest(event=event, repository=repository, ref=ref):
+ self.assertFalse(release.eligible_release(event, repository, ref, sha, pages))
+ for key, value in (
+ ("merged_at", None),
+ ("merge_commit_sha", "b" * 40),
+ ("base", {"ref": "master", "repo": {"full_name": release.GITHUB_REPOSITORY}}),
+ ("base", {"ref": "s3-li-2.49.1", "repo": {"full_name": "someone/fork"}}),
+ ):
+ other = copy.deepcopy(pull)
+ other[key] = value
+ with self.subTest(key=key, value=value):
+ self.assertFalse(
+ release.eligible_release("push", release.GITHUB_REPOSITORY, release.RELEASE_REF, sha, [[other]])
+ )
+
+ def test_selection_cli_writes_github_outputs(self):
+ with TemporaryDirectory() as directory:
+ output = Path(directory) / "output"
+ for event, expected in (("push", "false"), ("workflow_dispatch", "true")):
+ subprocess.run(
+ [sys.executable, SPEC.origin, "--select"],
+ input=json.dumps([]),
+ capture_output=True,
+ text=True,
+ check=True,
+ env={
+ "GITHUB_EVENT_NAME": event,
+ "GITHUB_REPOSITORY": release.GITHUB_REPOSITORY,
+ "GITHUB_REF": release.RELEASE_REF,
+ "GITHUB_SHA": "a" * 40,
+ "GITHUB_OUTPUT": str(output),
+ "PYTHONDONTWRITEBYTECODE": "1",
+ },
+ )
+ self.assertEqual(output.read_text(), f"eligible={expected}\n")
+ output.unlink()
+
+ def test_prepare_cli_selects_committed_or_requested_version(self):
+ with TemporaryDirectory() as directory:
+ output = Path(directory) / "output"
+ for event, requested, expected in (
+ ("push", "", None),
+ ("workflow_dispatch", VERSION, VERSION),
+ ):
+ env = {
+ "GITHUB_EVENT_NAME": event,
+ "GITHUB_OUTPUT": str(output),
+ "RELEASE_VERSION": requested,
+ }
+ with self.subTest(event=event), patch.dict(os.environ, env, clear=True), \
+ patch.object(sys, "argv", ["check-linkedin-release.py", "--prepare"]), \
+ patch.object(release, "prepare_release", return_value=VERSION) as prepare:
+ release.main()
+ prepare.assert_called_once_with(Path("pom.xml"), expected)
+ self.assertEqual(output.read_text(), f"version={VERSION}\n")
+ output.unlink()
+
+ def test_uses_committed_version_without_changing_reactor_profile_poms_or_templates(self):
+ with TemporaryDirectory() as directory:
+ root = Path(directory)
+ pom = self.pom()
+ modules = ET.SubElement(pom, f"{{{release.NAMESPACE['m']}}}modules")
+ ET.SubElement(modules, f"{{{release.NAMESPACE['m']}}}module").text = "child"
+ profiles = ET.SubElement(pom, f"{{{release.NAMESPACE['m']}}}profiles")
+ profile = ET.SubElement(profiles, f"{{{release.NAMESPACE['m']}}}profile")
+ profile_modules = ET.SubElement(profile, f"{{{release.NAMESPACE['m']}}}modules")
+ ET.SubElement(profile_modules, f"{{{release.NAMESPACE['m']}}}module").text = "profile-child"
+ (root / "pom.xml").write_text(ET.tostring(pom, encoding="unicode"))
+ for name in ("child", "profile-child"):
+ (root / name).mkdir()
+ (root / name / "pom.xml").write_text(
+ ''
+ '\n'
+ f'{VERSION}'
+ f'{VERSION}'
+ '1.0'
+ )
+ (root / "template").mkdir()
+ (root / "template/pom.xml").write_text(f"template {VERSION}")
+ opener = MagicMock(side_effect=urllib.error.HTTPError("url", 404, "missing", {}, None))
+ originals = {path: path.read_bytes() for path in root.rglob("pom.xml")}
+ version = release.prepare_release(root / "pom.xml", opener=opener)
+ self.assertEqual(version, VERSION)
+ self.assertEqual(len(release.validate_fork_versions(root / "pom.xml", version)), 3)
+ for path, original in originals.items():
+ self.assertEqual(path.read_bytes(), original)
+ self.assertEqual(opener.call_count, 4)
+
+ def test_mismatched_manual_version_or_existing_release_does_not_change_poms(self):
+ with TemporaryDirectory() as directory:
+ path = Path(directory) / "pom.xml"
+ original = ET.tostring(self.pom(), encoding="unicode")
+ path.write_text(original)
+ for expected in ("", "2.49.1-li-0.6", "123\nother=value", "$(echo unsafe)"):
+ opener = MagicMock()
+ with self.subTest(expected=expected), self.assertRaises(ValueError):
+ release.prepare_release(path, expected, opener)
+ opener.assert_not_called()
+ self.assertEqual(path.read_text(), original)
+ for opener in (
+ MagicMock(),
+ MagicMock(side_effect=urllib.error.HTTPError("url", 403, "forbidden", {}, None)),
+ MagicMock(side_effect=urllib.error.URLError("network failure")),
+ ):
+ with self.assertRaises((ValueError, urllib.error.URLError)):
+ release.prepare_release(path, opener=opener)
+ self.assertEqual(path.read_text(), original)
+
+ def test_preparation_fails_before_network_for_inconsistent_source_versions(self):
+ with TemporaryDirectory() as directory:
+ path = Path(directory) / "pom.xml"
+ pom = self.pom()
+ dependency = ET.SubElement(pom, f"{{{release.NAMESPACE['m']}}}dependency")
+ ET.SubElement(dependency, f"{{{release.NAMESPACE['m']}}}version").text = "2.49.1-li-0.4"
+ path.write_text(ET.tostring(pom, encoding="unicode"))
+ opener = MagicMock()
+ with self.assertRaisesRegex(ValueError, "Inconsistent fork version"):
+ release.prepare_release(path, opener=opener)
+ opener.assert_not_called()
+
+ def test_reruns_keep_the_same_version(self):
+ with TemporaryDirectory() as directory:
+ path = Path(directory) / "pom.xml"
+ original = ET.tostring(self.pom(), encoding="unicode")
+ versions = []
+ for _ in range(2):
+ path.write_text(original)
+ opener = MagicMock(side_effect=urllib.error.HTTPError("url", 404, "missing", {}, None))
+ versions.append(release.prepare_release(path, VERSION, opener))
+ self.assertEqual(versions[0], versions[1])
+ self.assertEqual(versions[0], VERSION)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
new file mode 100644
index 000000000000..215c93dc4d32
--- /dev/null
+++ b/.github/workflows/maven-build.yml
@@ -0,0 +1,40 @@
+name: Maven Build
+
+on:
+ push:
+ branches:
+ - '**'
+ pull_request:
+
+jobs:
+ release-checks:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ persist-credentials: false
+ - name: Test release preflight without credentials or network
+ run: python3 -m unittest discover -s .github/scripts -p 'test_*.py'
+
+ build:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ java: [8, 11]
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up JDK
+ uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: ${{ matrix.java }}
+ cache: maven
+
+ - name: Build with Maven (no tests, no deploy)
+ run: mvn -B clean install -DskipTests
diff --git a/.github/workflows/publish-linkedin.yml b/.github/workflows/publish-linkedin.yml
new file mode 100644
index 000000000000..46915258f06d
--- /dev/null
+++ b/.github/workflows/publish-linkedin.yml
@@ -0,0 +1,133 @@
+name: Publish LinkedIn SDK
+
+on:
+ push:
+ branches:
+ - s3-li-2.49.1
+ workflow_dispatch:
+ inputs:
+ version:
+ description: Exact version already committed in the release branch POMs
+ required: true
+ type: string
+ dry_run:
+ description: Build and verify only; do not upload to JFrog
+ required: true
+ default: true
+ type: boolean
+
+permissions:
+ contents: read
+
+concurrency:
+ group: publish-linkedin-sdk
+ cancel-in-progress: false
+ queue: max
+
+jobs:
+ select:
+ if: github.repository == 'linkedin/li-aws-sdk-java-v2' && github.ref == 'refs/heads/s3-li-2.49.1'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ pull-requests: read
+ outputs:
+ eligible: ${{ steps.trigger.outputs.eligible }}
+ steps:
+ - name: Checkout the selected release-branch commit
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - name: Select manual runs or an exact merged PR commit
+ id: trigger
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
+ gh api --paginate --slurp --method GET \
+ "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" -f per_page=100 \
+ > "$RUNNER_TEMP/release-pulls.json"
+ python3 .github/scripts/check-linkedin-release.py --select < "$RUNNER_TEMP/release-pulls.json"
+ else
+ python3 .github/scripts/check-linkedin-release.py --select
+ fi
+
+ publish:
+ needs: select
+ if: needs.select.outputs.eligible == 'true' && github.repository == 'linkedin/li-aws-sdk-java-v2' && github.ref == 'refs/heads/s3-li-2.49.1'
+ runs-on: ubuntu-latest
+ timeout-minutes: 180
+ environment: jfrog-publish
+ steps:
+ - name: Checkout the selected release-branch commit
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+
+ - name: Set up JDK
+ uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4
+ with:
+ distribution: temurin
+ java-version: '11'
+ server-id: central
+ server-username: ARTIFACTORY_USER
+ server-password: ARTIFACTORY_PASSWORD
+ settings-path: ${{ runner.temp }}
+
+ - name: Validate committed release version and destination
+ id: release
+ env:
+ RELEASE_VERSION: ${{ inputs.version }}
+ run: python3 .github/scripts/check-linkedin-release.py --prepare
+
+ # Some unit tests build clients through the default credentials chain.
+ # Use a fake profile file rather than env vars so the credential-provider
+ # tests, which control env vars and system properties, are unaffected.
+ - name: Configure fake AWS credentials for unit tests
+ run: |
+ mkdir -p ~/.aws
+ printf '[default]\naws_access_key_id = test-access-key\naws_secret_access_key = test-secret-key\n' > ~/.aws/credentials
+
+ - name: Build and verify the complete SDK reactor
+ env:
+ AWS_REGION: us-east-1
+ run: ./mvnw --batch-mode --no-transfer-progress clean verify
+
+ - name: Recheck publication state after the build
+ if: ${{ github.event_name == 'push' || !inputs.dry_run }}
+ env:
+ RELEASE_VERSION: ${{ steps.release.outputs.version }}
+ run: python3 .github/scripts/check-linkedin-release.py
+
+ - name: Publish the complete SDK reactor
+ if: ${{ github.event_name == 'push' || !inputs.dry_run }}
+ env:
+ ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
+ ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
+ run: |
+ if [[ -z "$ARTIFACTORY_USER" || -z "$ARTIFACTORY_PASSWORD" ]]; then
+ echo "::error::Configure ARTIFACTORY_USER and ARTIFACTORY_PASSWORD in the jfrog-publish environment."
+ exit 1
+ fi
+ ./mvnw --batch-mode --no-transfer-progress \
+ --settings "$RUNNER_TEMP/settings.xml" deploy -DskipTests
+
+ - name: Record release result
+ env:
+ RELEASE_VERSION: ${{ steps.release.outputs.version }}
+ DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
+ run: |
+ {
+ printf 'Version: `%s`\n\n' "$RELEASE_VERSION"
+ printf 'Source commit: `%s`\n\n' "$GITHUB_SHA"
+ printf 'Dry run: `%s`\n\n' "$DRY_RUN"
+ printf 'Destination: https://linkedin.jfrog.io/artifactory/li-aws-sdk-java-v2\n\n'
+ printf 'ELR import and consumer release cooldown are separate from publication.\n'
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ - name: Remove Maven publishing settings
+ if: always()
+ run: rm -f "$RUNNER_TEMP/settings.xml"
diff --git a/README.md b/README.md
index 0b9ebbcbfddd..504fd4d74429 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,8 @@ artifact source.
## Getting Started
+For this fork's release process, see [Publishing the LinkedIn SDK fork](docs/LinkedInPublishing.md).
+
#### Sign up for AWS ####
Before you begin, you need an AWS account. Please see the [Sign Up for AWS][docs-signup] section of
diff --git a/archetypes/archetype-app-quickstart/pom.xml b/archetypes/archetype-app-quickstart/pom.xml
index 33d35ab703fb..555fd227c5d5 100644
--- a/archetypes/archetype-app-quickstart/pom.xml
+++ b/archetypes/archetype-app-quickstart/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/archetypes/archetype-lambda/pom.xml b/archetypes/archetype-lambda/pom.xml
index 42128b5cac0c..77d06d876529 100644
--- a/archetypes/archetype-lambda/pom.xml
+++ b/archetypes/archetype-lambda/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
archetype-lambda
diff --git a/archetypes/archetype-tools/pom.xml b/archetypes/archetype-tools/pom.xml
index d007c36afe20..3b4590185197 100644
--- a/archetypes/archetype-tools/pom.xml
+++ b/archetypes/archetype-tools/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/archetypes/pom.xml b/archetypes/pom.xml
index 8dffb83ade0a..40e272ec4aec 100644
--- a/archetypes/pom.xml
+++ b/archetypes/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
archetypes
diff --git a/aws-sdk-java/pom.xml b/aws-sdk-java/pom.xml
index f5d067ebd3e0..7f5a65a9c239 100644
--- a/aws-sdk-java/pom.xml
+++ b/aws-sdk-java/pom.xml
@@ -17,7 +17,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
../pom.xml
aws-sdk-java
diff --git a/bom-internal/pom.xml b/bom-internal/pom.xml
index ca44993ec314..b8b76e196a56 100644
--- a/bom-internal/pom.xml
+++ b/bom-internal/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/bom/pom.xml b/bom/pom.xml
index d16c6a162d84..3fc0be161224 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -17,7 +17,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
../pom.xml
bom
diff --git a/bundle-logging-bridge/pom.xml b/bundle-logging-bridge/pom.xml
index ab6e905b2156..e4a5228b52ac 100644
--- a/bundle-logging-bridge/pom.xml
+++ b/bundle-logging-bridge/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
bundle-logging-bridge
jar
diff --git a/bundle-sdk/pom.xml b/bundle-sdk/pom.xml
index 27542789cad2..3bdc5e69e7b3 100644
--- a/bundle-sdk/pom.xml
+++ b/bundle-sdk/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
bundle-sdk
jar
diff --git a/bundle/pom.xml b/bundle/pom.xml
index e8f3adee7ad2..d053f961739e 100644
--- a/bundle/pom.xml
+++ b/bundle/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
bundle
jar
diff --git a/codegen-lite-maven-plugin/pom.xml b/codegen-lite-maven-plugin/pom.xml
index d071ea41b611..ed18fee0d8a2 100644
--- a/codegen-lite-maven-plugin/pom.xml
+++ b/codegen-lite-maven-plugin/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
../pom.xml
codegen-lite-maven-plugin
diff --git a/codegen-lite/pom.xml b/codegen-lite/pom.xml
index 02cdfbf3b7ed..a4b6ef1329fb 100644
--- a/codegen-lite/pom.xml
+++ b/codegen-lite/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
codegen-lite
AWS Java SDK :: Code Generator Lite
diff --git a/codegen-maven-plugin/pom.xml b/codegen-maven-plugin/pom.xml
index c23a05b9ec85..37f1c8a40289 100644
--- a/codegen-maven-plugin/pom.xml
+++ b/codegen-maven-plugin/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
../pom.xml
codegen-maven-plugin
diff --git a/codegen/pom.xml b/codegen/pom.xml
index b7e31fb5a0cb..1774e16510f9 100644
--- a/codegen/pom.xml
+++ b/codegen/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.49.1
+ 2.49.1-li-0.1
codegen
AWS Java SDK :: Code Generator
diff --git a/core/annotations/pom.xml b/core/annotations/pom.xml
index 0658dfd870c7..a424030ec09c 100644
--- a/core/annotations/pom.xml
+++ b/core/annotations/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/arns/pom.xml b/core/arns/pom.xml
index 6d90d3eb4b04..8a6e22d6667e 100644
--- a/core/arns/pom.xml
+++ b/core/arns/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/auth-crt/pom.xml b/core/auth-crt/pom.xml
index de0fab33b005..62726ae89150 100644
--- a/core/auth-crt/pom.xml
+++ b/core/auth-crt/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
auth-crt
diff --git a/core/auth/pom.xml b/core/auth/pom.xml
index 6b914ee39e75..606a30714e8c 100644
--- a/core/auth/pom.xml
+++ b/core/auth/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
auth
diff --git a/core/aws-core/pom.xml b/core/aws-core/pom.xml
index a959a55ffaf3..3a3917947220 100644
--- a/core/aws-core/pom.xml
+++ b/core/aws-core/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
aws-core
diff --git a/core/checksums-spi/pom.xml b/core/checksums-spi/pom.xml
index eab72ed96b30..a3bfbbcd381f 100644
--- a/core/checksums-spi/pom.xml
+++ b/core/checksums-spi/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
checksums-spi
diff --git a/core/checksums/pom.xml b/core/checksums/pom.xml
index 232e436190a2..bbc068cbf918 100644
--- a/core/checksums/pom.xml
+++ b/core/checksums/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
checksums
diff --git a/core/crt-core/pom.xml b/core/crt-core/pom.xml
index 7c15de1861f2..b19c526f693c 100644
--- a/core/crt-core/pom.xml
+++ b/core/crt-core/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
crt-core
diff --git a/core/endpoints-spi/pom.xml b/core/endpoints-spi/pom.xml
index b380bbda2d74..bc29408cd8fc 100644
--- a/core/endpoints-spi/pom.xml
+++ b/core/endpoints-spi/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/http-auth-aws-crt/pom.xml b/core/http-auth-aws-crt/pom.xml
index 874b2034420a..787cee2db2e0 100644
--- a/core/http-auth-aws-crt/pom.xml
+++ b/core/http-auth-aws-crt/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
http-auth-aws-crt
diff --git a/core/http-auth-aws-eventstream/pom.xml b/core/http-auth-aws-eventstream/pom.xml
index 095693268ebb..f63fbe0f567e 100644
--- a/core/http-auth-aws-eventstream/pom.xml
+++ b/core/http-auth-aws-eventstream/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
http-auth-aws-eventstream
diff --git a/core/http-auth-aws/pom.xml b/core/http-auth-aws/pom.xml
index 340083eaf429..a63e6bfe1955 100644
--- a/core/http-auth-aws/pom.xml
+++ b/core/http-auth-aws/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
http-auth-aws
diff --git a/core/http-auth-spi/pom.xml b/core/http-auth-spi/pom.xml
index ca75d81380f8..ea072ac56205 100644
--- a/core/http-auth-spi/pom.xml
+++ b/core/http-auth-spi/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
http-auth-spi
diff --git a/core/http-auth/pom.xml b/core/http-auth/pom.xml
index 8433983c097f..95e9205c3427 100644
--- a/core/http-auth/pom.xml
+++ b/core/http-auth/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
http-auth
diff --git a/core/identity-spi/pom.xml b/core/identity-spi/pom.xml
index f8db44ad6156..145bef110e56 100644
--- a/core/identity-spi/pom.xml
+++ b/core/identity-spi/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
identity-spi
diff --git a/core/imds/pom.xml b/core/imds/pom.xml
index 843d46b6c42f..27cf9b22f381 100644
--- a/core/imds/pom.xml
+++ b/core/imds/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
imds
diff --git a/core/json-utils/pom.xml b/core/json-utils/pom.xml
index bed0e5ad1f0a..1da2b5a22376 100644
--- a/core/json-utils/pom.xml
+++ b/core/json-utils/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/metrics-spi/pom.xml b/core/metrics-spi/pom.xml
index a83361e6f847..63bc3c25d8d5 100644
--- a/core/metrics-spi/pom.xml
+++ b/core/metrics-spi/pom.xml
@@ -5,7 +5,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/pom.xml b/core/pom.xml
index ac802cd05b6c..7402167cff86 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
core
diff --git a/core/profiles/pom.xml b/core/profiles/pom.xml
index 5632d915b824..72362d600567 100644
--- a/core/profiles/pom.xml
+++ b/core/profiles/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
profiles
diff --git a/core/protocols/aws-cbor-protocol/pom.xml b/core/protocols/aws-cbor-protocol/pom.xml
index 6b87c010779c..b7b04f476878 100644
--- a/core/protocols/aws-cbor-protocol/pom.xml
+++ b/core/protocols/aws-cbor-protocol/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/aws-json-protocol/pom.xml b/core/protocols/aws-json-protocol/pom.xml
index 6b18fd034ea7..8a89effc46d6 100644
--- a/core/protocols/aws-json-protocol/pom.xml
+++ b/core/protocols/aws-json-protocol/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/aws-query-protocol/pom.xml b/core/protocols/aws-query-protocol/pom.xml
index a6dc7b01cbff..ba59be0fd7f5 100644
--- a/core/protocols/aws-query-protocol/pom.xml
+++ b/core/protocols/aws-query-protocol/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/aws-xml-protocol/pom.xml b/core/protocols/aws-xml-protocol/pom.xml
index 0d82e5c3e27f..ccfbdc805e42 100644
--- a/core/protocols/aws-xml-protocol/pom.xml
+++ b/core/protocols/aws-xml-protocol/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/pom.xml b/core/protocols/pom.xml
index e5dbf5fe3a87..63f0e3019cba 100644
--- a/core/protocols/pom.xml
+++ b/core/protocols/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/protocol-core/pom.xml b/core/protocols/protocol-core/pom.xml
index d25ca6d9ad61..12f4cc3eba93 100644
--- a/core/protocols/protocol-core/pom.xml
+++ b/core/protocols/protocol-core/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/protocols/smithy-rpcv2-protocol/pom.xml b/core/protocols/smithy-rpcv2-protocol/pom.xml
index b1a4f1ef3f0a..bf3d9575902a 100644
--- a/core/protocols/smithy-rpcv2-protocol/pom.xml
+++ b/core/protocols/smithy-rpcv2-protocol/pom.xml
@@ -20,7 +20,7 @@
protocols
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/regions/pom.xml b/core/regions/pom.xml
index fbb3efc688e8..f4afdea206c7 100644
--- a/core/regions/pom.xml
+++ b/core/regions/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
regions
diff --git a/core/retries-spi/pom.xml b/core/retries-spi/pom.xml
index 767df8c1147b..8ce73ab1c8b9 100644
--- a/core/retries-spi/pom.xml
+++ b/core/retries-spi/pom.xml
@@ -20,7 +20,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/retries/pom.xml b/core/retries/pom.xml
index 34fe5ff254ea..fb9cb2aecec9 100644
--- a/core/retries/pom.xml
+++ b/core/retries/pom.xml
@@ -21,7 +21,7 @@
core
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/core/sdk-core/pom.xml b/core/sdk-core/pom.xml
index bfe38e2621d9..d2550a9012e7 100644
--- a/core/sdk-core/pom.xml
+++ b/core/sdk-core/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
core
- 2.49.1
+ 2.49.1-li-0.1
sdk-core
AWS Java SDK :: SDK Core
diff --git a/docs/LinkedInPublishing.md b/docs/LinkedInPublishing.md
new file mode 100644
index 000000000000..de2bd82bf1a0
--- /dev/null
+++ b/docs/LinkedInPublishing.md
@@ -0,0 +1,106 @@
+# Publishing the LinkedIn SDK fork
+
+The `Publish LinkedIn SDK` GitHub Actions workflow automatically builds, verifies,
+and deploys the complete Maven reactor after a PR merges into `s3-li-2.49.1`.
+Manual runs remain available and default to dry run. The destination is the existing
+`https://linkedin.jfrog.io/artifactory/li-aws-sdk-java-v2` repository. ELR imports
+the published coordinates into internal Artifactory separately. This is the same
+publish-then-import model used by Ambry, not a direct upload to internal Artifactory.
+
+## One-time administrator setup
+
+1. Merge the workflow, release-check script, and this document into
+ `s3-li-2.49.1`. The workflow must also be present on the repository's default
+ branch (`master`) for GitHub to expose `workflow_dispatch`. Carry over these
+ files only; do not merge the fork's release code into upstream master.
+2. Configure the GitHub environment `jfrog-publish` to allow only the branch
+ `s3-li-2.49.1`, not tags. Remove required reviewers to enable the requested
+ unattended publication policy; environment settings are separate from YAML.
+ This also removes the approval gate for manual uploads. Protect the release
+ branch with reviewed PRs before enabling unattended publication: merged code
+ runs with publishing authority, and other workflows on the allowed branch
+ could also reference these environment secrets.
+3. Add environment secrets `ARTIFACTORY_USER` and `ARTIFACTORY_PASSWORD`.
+ The identity must have write access to the existing `li-aws-sdk-java-v2`
+ repository. JFrog's **Set Me Up > Maven > Generate Token & Create Instructions**
+ supplies the Maven username and identity token. Store that username in
+ `ARTIFACTORY_USER` and the token in `ARTIFACTORY_PASSWORD`; the secret name does
+ not require an account password. Do not paste credentials into code, logs, or
+ chat. Revoke exposed tokens and replace the GitHub secret with a fresh token.
+ Assign an owner to rotate credentials before expiry. A personal deploy grant
+ may end before its token expires; replace temporary personal credentials with
+ a publish-platform-approved automation identity. Do not assume service accounts
+ or GitHub OIDC are already provisioned.
+4. Ensure JFrog permissions prohibit overwriting release artifacts. The workflow
+ serializes its own uploads and checks representative coordinates for existing
+ or partial publication, but cannot atomically exclude another publisher.
+
+No JFrog secrets are available to the existing pull-request build or release-selection
+job. A release-branch push is eligible for automatic publication only if GitHub
+associates its exact SHA with a merged PR targeting that branch in this repository.
+Direct pushes and unmerged or differently targeted PRs do not publish. The workflow
+checks out that immutable push SHA, never the unmerged PR head. Selection needs
+read-only pull-request access; publishing retains read-only contents access.
+Only the upload step receives JFrog credentials; Maven settings
+contain environment references and are deleted at job completion. There is no
+dependency cache in this credentialed workflow.
+
+The workflow serializes builds and uploads and queues up to 100 pending runs.
+GitHub cancels additional runs if that queue fills. Merging this workflow change
+can itself trigger an upload, so complete credential rotation and repository
+protection setup before enabling it.
+
+## Automatic release
+
+Each release PR must explicitly bump the final integer in the fork version,
+for example `2.49.1-li-0.1` to `2.49.1-li-0.2`, consistently across the actual
+reactor and profile POMs. The workflow publishes the committed version unchanged;
+it does not generate versions, edit POMs, or commit version bumps back to the branch.
+Preflight validates consistency and refuses an already-published version, so a PR
+that retains a published version cannot publish again. Coordinate concurrent
+release PRs so they do not reuse the same version.
+
+Reruns use the same committed version: a completed or partially uploaded release is
+refused rather than silently creating a new version. After validation, publication
+requires a successful full-reactor `clean verify` and another absence check before
+`deploy -DskipTests`. The version and source SHA appear in the run summary.
+The verification step supplies `AWS_REGION=us-east-1` for generated client tests
+that require a signing region even when testing custom endpoints; it does not
+provide AWS credentials.
+Do not merge further release changes blindly after a partial upload; follow the
+recovery instructions below.
+
+## Manual release or dry run
+
+1. Commit the intended version consistently across the fork's POMs and review
+ the release-branch changes. Preflight checks literal fork versions in the actual
+ reactor and profile modules, excluding archetype templates and generated POMs.
+ Manual runs require the requested version to match the committed POMs.
+2. In Actions, select **Publish LinkedIn SDK**, choose branch `s3-li-2.49.1`,
+ enter the exact committed version, and leave `dry_run=true`.
+ Confirm the source SHA and successful full-reactor `clean verify`.
+3. Dispatch the same reviewed commit/version with `dry_run=false` to upload without
+ a separate environment approval. If the branch moved since the dry run, review
+ the new SHA; both runs build the SHA selected when dispatched.
+4. The workflow checks the root version and destination, refuses representative
+ existing release coordinates, runs `clean verify`, then runs `deploy` for the
+ complete reactor. The deploy invocation skips unit tests already run by verify.
+ It does not activate the upstream `publishing` profile, which targets Sonatype.
+5. Confirm Maven reports success for the complete reactor and inspect the published
+ parent/BOM, S3 and Netty POMs, JARs, and normal attached artifacts in JFrog.
+ Maven deployment is not transactional. If it fails partway, stop and have the
+ repository owner assess the uploaded artifacts; do not bypass the preflight
+ or blindly overwrite a partial release.
+6. Confirm ELR import (or request it through go/elr). Observe the seven-day
+ dependency cooldown or obtain an incident exception before consumption.
+ Update the consumer dependencies and verify the actual resolved
+ `netty-nio-client` version; publication alone does not roll the fix out.
+
+## Local workflow checks
+
+```bash
+python3 -m unittest discover -s .github/scripts -p 'test_*.py'
+RELEASE_VERSION=2.49.1-li-0.2 python3 .github/scripts/check-linkedin-release.py
+```
+
+The second command makes read-only requests to JFrog; it never uploads artifacts.
diff --git a/http-client-spi/pom.xml b/http-client-spi/pom.xml
index 75c6ed442d54..40d05e812382 100644
--- a/http-client-spi/pom.xml
+++ b/http-client-spi/pom.xml
@@ -22,7 +22,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
http-client-spi
AWS Java SDK :: HTTP Client Interface
diff --git a/http-clients/apache-client/pom.xml b/http-clients/apache-client/pom.xml
index 2e18955e7ad5..d44ee557b8cf 100644
--- a/http-clients/apache-client/pom.xml
+++ b/http-clients/apache-client/pom.xml
@@ -21,7 +21,7 @@
http-clients
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
apache-client
diff --git a/http-clients/apache5-client/pom.xml b/http-clients/apache5-client/pom.xml
index 877ad649572d..d93f264307bb 100644
--- a/http-clients/apache5-client/pom.xml
+++ b/http-clients/apache5-client/pom.xml
@@ -21,7 +21,7 @@
http-clients
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
apache5-client
diff --git a/http-clients/aws-crt-client/pom.xml b/http-clients/aws-crt-client/pom.xml
index a0af7755d101..60e77932bca0 100644
--- a/http-clients/aws-crt-client/pom.xml
+++ b/http-clients/aws-crt-client/pom.xml
@@ -21,7 +21,7 @@
http-clients
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/http-clients/netty-nio-client/pom.xml b/http-clients/netty-nio-client/pom.xml
index ccfc282e84b5..fab24a0b7a7a 100644
--- a/http-clients/netty-nio-client/pom.xml
+++ b/http-clients/netty-nio-client/pom.xml
@@ -20,7 +20,7 @@
http-clients
software.amazon.awssdk
- 2.49.1
+ 2.49.1-li-0.1
4.0.0
diff --git a/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java b/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java
index 627addee730b..083960a23f89 100644
--- a/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java
+++ b/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java
@@ -35,8 +35,12 @@
import io.netty.channel.Channel;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.DecoderResult;
+import io.netty.handler.codec.http.DefaultFullHttpRequest;
import io.netty.handler.codec.http.DefaultHttpContent;
+import io.netty.handler.codec.http.EmptyHttpHeaders;
+import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpContent;
+import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpRequest;
@@ -241,14 +245,29 @@ private void makeRequest() {
}
private void writeRequest(HttpRequest request) {
- addWriteTimeoutHandlers();
- StreamedRequest streamedRequest = new StreamedRequest(request,
- context.executeRequest().requestContentPublisher());
+ if (shouldWriteAsEmptyFullRequest(request)) {
+ // Still subscribe to the (empty) request publisher: some bodies, e.g.
+ // AsyncRequestBody.forBlockingInputStream(0L), block their producer until they are subscribed to.
+ context.executeRequest().requestContentPublisher().subscribe(new EmptyBodySubscriber(request));
+ return;
+ }
+ writeToChannel(new StreamedRequest(request, context.executeRequest().requestContentPublisher()));
+ }
- channel.writeAndFlush(streamedRequest)
+ private void writeToChannel(HttpRequest requestToWrite) {
+ addWriteTimeoutHandlers();
+ channel.writeAndFlush(requestToWrite)
.addListener(wireCall -> {
// Done writing so remove the idle write timeout handler
removeWriteTimeoutHandlers();
+ if (!wireCall.isSuccess() && isResponseCompletedSuccessfully()) {
+ // The server may respond and close/reset the stream before our END_STREAM has been written
+ // (e.g. RST_STREAM(NO_ERROR), RFC 9113 section 8.1). The response has already been delivered
+ // and the channel released, so this late write failure must not fail the request.
+ log.debug(channel, () -> "Ignoring request write failure after the response completed for "
+ + endpoint(), wireCall.cause());
+ return;
+ }
if (wireCall.isSuccess()) {
NettyRequestMetrics.publishHttp2StreamMetrics(context.metricCollector(), channel);
@@ -300,6 +319,121 @@ private void addWriteTimeoutHandlers() {
new WriteIdleTimeoutHandler(context.configuration().writeTimeoutMillis()));
}
+ private boolean isResponseCompletedSuccessfully() {
+ return executeFuture.isDone() && !executeFuture.isCompletedExceptionally();
+ }
+
+ /**
+ * For HTTP/2 requests without a body, send a single HEADERS frame with END_STREAM instead of HEADERS followed by
+ * a separate empty DATA(END_STREAM) frame. Otherwise the server can respond and reset the stream before the
+ * trailing empty DATA frame is written, which fails a request whose response was already received.
+ */
+ private boolean shouldWriteAsEmptyFullRequest(HttpRequest request) {
+ if (ChannelAttributeKey.getProtocolNow(channel) != Protocol.HTTP2
+ || context.executeRequest().fullDuplex()
+ || is100ContinueExpected()) {
+ return false;
+ }
+ Optional publisherLength = context.executeRequest().requestContentPublisher().contentLength();
+ if (!publisherLength.isPresent() || publisherLength.get() != 0L) {
+ return false;
+ }
+ String contentLength = request.headers().get(HttpHeaderNames.CONTENT_LENGTH);
+ return (contentLength == null || "0".equals(contentLength.trim()))
+ && !request.headers().contains(HttpHeaderNames.TRANSFER_ENCODING);
+ }
+
+ private static FullHttpRequest toEmptyFullRequest(HttpRequest request) {
+ return new DefaultFullHttpRequest(request.protocolVersion(), request.method(), request.uri(),
+ Unpooled.EMPTY_BUFFER, request.headers(), EmptyHttpHeaders.INSTANCE);
+ }
+
+ /**
+ * Drives the lifecycle of a request publisher that declared a zero content length, then writes the request as a
+ * single {@link FullHttpRequest} (HEADERS with END_STREAM) once the publisher completes. Publisher errors fail the
+ * request, and the subscription is cancelled if the request fails or is cancelled first.
+ */
+ private final class EmptyBodySubscriber implements Subscriber {
+ private final HttpRequest request;
+ private final boolean contentLengthHeaderPresent;
+ private Subscription subscription;
+ private boolean done;
+
+ private EmptyBodySubscriber(HttpRequest request) {
+ this.request = request;
+ this.contentLengthHeaderPresent = request.headers().contains(HttpHeaderNames.CONTENT_LENGTH);
+ }
+
+ @Override
+ public void onSubscribe(Subscription s) {
+ if (subscription != null) {
+ s.cancel();
+ return;
+ }
+ subscription = s;
+ executeFuture.whenComplete((r, t) -> {
+ if (t != null) {
+ s.cancel();
+ }
+ });
+ s.request(Long.MAX_VALUE);
+ }
+
+ @Override
+ public void onNext(ByteBuffer byteBuffer) {
+ if (done || !byteBuffer.hasRemaining()) {
+ return;
+ }
+ subscription.cancel();
+ if (contentLengthHeaderPresent) {
+ // Same as StreamedRequest: content beyond the declared Content-Length (0) is not sent.
+ complete();
+ } else {
+ onError(new IllegalStateException("Request content publisher declared a content length of 0 but "
+ + "published " + byteBuffer.remaining() + " bytes."));
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ if (done) {
+ return;
+ }
+ done = true;
+ NettyUtils.doInEventLoop(channel.eventLoop(), () -> {
+ if (executeFuture.isDone()) {
+ // The request already completed or was cancelled; the publisher error raced with it.
+ return;
+ }
+ closeAndRelease(channel);
+ handleFailure(channel, () -> "Failed to read request content for " + endpoint(), t);
+ });
+ }
+
+ @Override
+ public void onComplete() {
+ complete();
+ }
+
+ private void complete() {
+ if (done) {
+ return;
+ }
+ done = true;
+ NettyUtils.doInEventLoop(channel.eventLoop(), () -> {
+ if (executeFuture.isDone()) {
+ return;
+ }
+ try {
+ writeToChannel(toEmptyFullRequest(request));
+ } catch (Throwable t) {
+ closeAndRelease(channel);
+ handleFailure(channel, () -> "Failed to make request to " + endpoint(), t);
+ }
+ });
+ }
+ }
+
/**
* It should explicitly trigger Read for the following situations:
*
diff --git a/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapter.java b/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapter.java
index 881f50f64624..88dbf23ead90 100644
--- a/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapter.java
+++ b/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapter.java
@@ -70,8 +70,10 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
// Convert and write the headers.
Http2Headers http2Headers = HttpConversionUtil.toHttp2Headers(httpMsg, false);
- endStream = msg instanceof FullHttpMessage && !((FullHttpMessage) msg).content().isReadable();
- ctx.write(new DefaultHttp2HeadersFrame(http2Headers), promiseAggregator.newPromise());
+ endStream = msg instanceof FullHttpMessage
+ && !((FullHttpMessage) msg).content().isReadable()
+ && ((FullHttpMessage) msg).trailingHeaders().isEmpty();
+ ctx.write(new DefaultHttp2HeadersFrame(http2Headers, endStream), promiseAggregator.newPromise());
}
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/H2ServerErrorTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/H2ServerErrorTest.java
index 8b640fb4226a..0a9f8c0d1399 100644
--- a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/H2ServerErrorTest.java
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/H2ServerErrorTest.java
@@ -35,6 +35,7 @@
import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
import io.netty.handler.codec.http2.Http2DataFrame;
import io.netty.handler.codec.http2.Http2Frame;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.Http2FrameCodec;
import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
import io.netty.handler.codec.http2.Http2Headers;
@@ -174,7 +175,8 @@ private class MightReturn500StreamFrameHandler extends SimpleChannelInboundHandl
@Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Frame frame) {
- if (frame instanceof Http2DataFrame) {
+ if (frame instanceof Http2DataFrame
+ || (frame instanceof Http2HeadersFrame && ((Http2HeadersFrame) frame).isEndStream())) {
DefaultHttp2DataFrame dataFrame = new DefaultHttp2DataFrame(true);
// returning 500 this is channel 1
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/PingTimeoutTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/PingTimeoutTest.java
index ccfcbd6c2a74..fe133a7503f2 100644
--- a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/PingTimeoutTest.java
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/PingTimeoutTest.java
@@ -38,6 +38,7 @@
import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
import io.netty.handler.codec.http2.Http2FrameLogger;
import io.netty.handler.codec.http2.Http2Headers;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.Http2MultiplexHandler;
import io.netty.handler.codec.http2.Http2Settings;
import io.netty.handler.logging.LogLevel;
@@ -241,16 +242,17 @@ private static final class StreamHandler extends SimpleChannelInboundHandler {
- DefaultHttp2DataFrame respData = new DefaultHttp2DataFrame(Unpooled.wrappedBuffer("hello".getBytes()), false);
- ctx.writeAndFlush(respData);
- }, 0, 2, TimeUnit.SECONDS);
- }
+ // Bodyless requests end the stream on the HEADERS frame; others end it with a DATA frame.
+ boolean requestEnded =
+ (http2Frame instanceof Http2DataFrame && ((Http2DataFrame) http2Frame).isEndStream())
+ || (http2Frame instanceof Http2HeadersFrame && ((Http2HeadersFrame) http2Frame).isEndStream());
+ if (requestEnded) {
+ Http2Headers headers = new DefaultHttp2Headers().status("200");
+ ctx.writeAndFlush(new DefaultHttp2HeadersFrame(headers, false));
+ ctx.executor().scheduleAtFixedRate(() -> {
+ DefaultHttp2DataFrame respData = new DefaultHttp2DataFrame(Unpooled.wrappedBuffer("hello".getBytes()), false);
+ ctx.writeAndFlush(respData);
+ }, 0, 2, TimeUnit.SECONDS);
}
}
}
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerCloseConnectionTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerCloseConnectionTest.java
index a84eca2d138a..b4431b8d4311 100644
--- a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerCloseConnectionTest.java
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerCloseConnectionTest.java
@@ -34,6 +34,7 @@
import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
import io.netty.handler.codec.http2.Http2DataFrame;
import io.netty.handler.codec.http2.Http2Frame;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.Http2FrameCodec;
import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
import io.netty.handler.codec.http2.Http2FrameLogger;
@@ -220,7 +221,8 @@ private class MightCloseConnectionStreamFrameHandler extends SimpleChannelInboun
@Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Frame frame) {
- if (frame instanceof Http2DataFrame) {
+ if (frame instanceof Http2DataFrame
+ || (frame instanceof Http2HeadersFrame && ((Http2HeadersFrame) frame).isEndStream())) {
// Not respond if this is channel 1
if (channelIds[0].equals(ctx.channel().parent().id().asShortText()) && failOnFirstChannel) {
ctx.channel().parent().close();
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerNotRespondingTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerNotRespondingTest.java
index af9a0204434b..04e34daed2e0 100644
--- a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerNotRespondingTest.java
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/fault/ServerNotRespondingTest.java
@@ -35,6 +35,7 @@
import io.netty.handler.codec.http2.DefaultHttp2PingFrame;
import io.netty.handler.codec.http2.Http2DataFrame;
import io.netty.handler.codec.http2.Http2Frame;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.Http2FrameCodec;
import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
import io.netty.handler.codec.http2.Http2FrameLogger;
@@ -261,7 +262,8 @@ private class MightNotRespondStreamFrameHandler extends SimpleChannelInboundHand
@Override
protected void channelRead0(ChannelHandlerContext ctx, Http2Frame frame) {
- if (frame instanceof Http2DataFrame) {
+ if (frame instanceof Http2DataFrame
+ || (frame instanceof Http2HeadersFrame && ((Http2HeadersFrame) frame).isEndStream())) {
// Not respond if this is channel 1
if (channelIds[0].equals(ctx.channel().parent().id().asShortText()) && notRespondOnFirstChannel) {
LOGGER.info(() -> "This is the first request, not responding" + ctx.channel());
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/EarlyResponseResetTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/EarlyResponseResetTest.java
new file mode 100644
index 000000000000..f8e66b0e7265
--- /dev/null
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/EarlyResponseResetTest.java
@@ -0,0 +1,462 @@
+/*
+ * 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.http.nio.netty.internal.http2;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.ServerSocketChannel;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpHeaderNames;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpServerCodec;
+import io.netty.handler.codec.http.HttpVersion;
+import io.netty.handler.codec.http2.DefaultHttp2Headers;
+import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
+import io.netty.handler.codec.http2.DefaultHttp2ResetFrame;
+import io.netty.handler.codec.http2.Http2Error;
+import io.netty.handler.codec.http2.Http2FrameCodec;
+import io.netty.handler.codec.http2.Http2FrameCodecBuilder;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
+import io.netty.util.ReferenceCountUtil;
+import io.reactivex.Flowable;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.reactivestreams.Publisher;
+import org.reactivestreams.Subscriber;
+import org.reactivestreams.Subscription;
+import software.amazon.awssdk.http.Protocol;
+import software.amazon.awssdk.http.SdkHttpFullRequest;
+import software.amazon.awssdk.http.SdkHttpMethod;
+import software.amazon.awssdk.http.SdkHttpResponse;
+import software.amazon.awssdk.http.async.AsyncExecuteRequest;
+import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
+import software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler;
+import software.amazon.awssdk.http.async.SdkHttpContentPublisher;
+import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
+
+/**
+ * A server may send a complete response and then RST_STREAM(NO_ERROR) before the client has finished sending its
+ * request (RFC 9113 section 8.1). The client must not discard the complete response in that case.
+ */
+public class EarlyResponseResetTest {
+ private static final int ITERATIONS = 200;
+
+ private final List requestHeadersEndStream = new CopyOnWriteArrayList<>();
+ private NioEventLoopGroup serverGroup;
+ private ServerSocketChannel serverChannel;
+ private SdkAsyncHttpClient netty;
+ private volatile boolean resetAfterResponse = true;
+ private volatile ChannelHandlerContext lastServerContext;
+ private volatile Http2HeadersFrame lastRequestHeaders;
+ private final CountDownLatch serverResponded = new CountDownLatch(1);
+
+ @BeforeEach
+ public void setup() throws InterruptedException {
+ serverGroup = new NioEventLoopGroup();
+ serverChannel = (ServerSocketChannel) new ServerBootstrap()
+ .channel(NioServerSocketChannel.class)
+ .group(serverGroup)
+ .childHandler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(SocketChannel ch) {
+ Http2FrameCodec codec = Http2FrameCodecBuilder.forServer()
+ .autoAckPingFrame(true)
+ .decoderEnforceMaxRstFramesPerWindow(0, 0)
+ .build();
+ ch.pipeline().addLast(codec);
+ ch.pipeline().addLast(new RespondThenResetHandler());
+ }
+ })
+ .localAddress(0)
+ .bind().await().channel();
+
+ netty = NettyNioAsyncHttpClient.builder()
+ .protocol(Protocol.HTTP2)
+ .maxConcurrency(1)
+ .build();
+ }
+
+ @AfterEach
+ public void teardown() throws InterruptedException {
+ netty.close();
+ serverChannel.close().await();
+ serverGroup.shutdownGracefully().await();
+ }
+
+ @Test
+ public void emptyBodyRequest_sendsEndStreamOnHeadersAndSucceeds() {
+ for (int i = 0; i < ITERATIONS; i++) {
+ execute(publisher(Optional.of(0L), Flowable.just(ByteBuffer.allocate(0))), new RecordingHandler()).join();
+ }
+ assertThat(requestHeadersEndStream).hasSize(ITERATIONS).containsOnly(true);
+ }
+
+ @Test
+ public void emptyBodyRequest_subscriptionDependentBody_isSubscribedAndSucceeds() throws Exception {
+ CountDownLatch subscribed = new CountDownLatch(1);
+ // Like AsyncRequestBody.forBlockingInputStream(0L): the body is only produced after it has been subscribed to.
+ Publisher body = s -> s.onSubscribe(new Subscription() {
+ @Override
+ public void request(long n) {
+ subscribed.countDown();
+ CompletableFuture.runAsync(s::onComplete);
+ }
+
+ @Override
+ public void cancel() {
+ }
+ });
+ RecordingHandler handler = new RecordingHandler();
+
+ execute(publisher(Optional.of(0L), body), handler).get(5, TimeUnit.SECONDS);
+
+ assertThat(subscribed.getCount()).isZero();
+ assertThat(requestHeadersEndStream).containsExactly(true);
+ assertThat(handler.errors).isEmpty();
+ }
+
+ @Test
+ public void emptyBodyRequest_publisherError_failsRequest() {
+ IllegalStateException failure = new IllegalStateException("boom");
+ RecordingHandler handler = new RecordingHandler();
+
+ CompletableFuture result = execute(publisher(Optional.of(0L), Flowable.error(failure)), handler);
+
+ assertThatThrownBy(() -> result.get(5, TimeUnit.SECONDS)).hasRootCause(failure);
+ assertThat(handler.errors).hasSize(1);
+ assertThat(requestHeadersEndStream).isEmpty();
+ }
+
+ @Test
+ public void streamedRequest_writeFailsAfterResponseCompleted_succeeds() throws Exception {
+ resetAfterResponse = false;
+ ControlledPublisher body = new ControlledPublisher();
+ RecordingHandler handler = new RecordingHandler();
+
+ CompletableFuture result = execute(publisher(Optional.empty(), body), handler);
+
+ // The server has sent a complete response while the request body (and so the request write promise) is
+ // still pending.
+ assertThat(serverResponded.await(5, TimeUnit.SECONDS)).isTrue();
+ assertThat(requestHeadersEndStream).containsExactly(false);
+ assertThat(result).isNotDone();
+
+ // Resetting the stream delivers the complete response to the client and closes the stream.
+ resetStream().sync();
+ result.get(5, TimeUnit.SECONDS);
+ assertThat(handler.responseComplete.await(5, TimeUnit.SECONDS)).isTrue();
+ assertThat(body.cancelled.await(5, TimeUnit.SECONDS)).isTrue();
+
+ // The request body completes only now, so the final request write (END_STREAM) fails on the closed stream
+ // strictly after the response completed. That late failure must not be reported to the response handler.
+ body.complete();
+ assertThat(handler.errored.await(1, TimeUnit.SECONDS)).isFalse();
+ assertThat(handler.errors).isEmpty();
+ assertThat(result).isCompletedWithValue(null);
+ }
+
+ @Test
+ public void emptyBodyRequest_cancelledWhileWaitingForBody_cancelsBodyAndSendsNothing() throws Exception {
+ ControlledPublisher body = new ControlledPublisher();
+ RecordingHandler handler = new RecordingHandler();
+
+ CompletableFuture result = execute(publisher(Optional.of(0L), body), handler);
+ assertThat(body.subscribed.await(5, TimeUnit.SECONDS)).isTrue();
+
+ result.cancel(true);
+ assertThat(body.cancelled.await(5, TimeUnit.SECONDS)).isTrue();
+
+ // A body that completes after cancellation must not cause the request to be written.
+ body.complete();
+ assertNoRequestSentAndConnectionStillUsable();
+ assertThat(result).isCancelled();
+ }
+
+ @Test
+ public void emptyBodyRequest_publisherErrorsAfterCancellation_errorIsNotReported() throws Exception {
+ ControlledPublisher body = new ControlledPublisher();
+ RecordingHandler handler = new RecordingHandler();
+
+ CompletableFuture result = execute(publisher(Optional.of(0L), body), handler);
+ assertThat(body.subscribed.await(5, TimeUnit.SECONDS)).isTrue();
+
+ result.cancel(true);
+ assertThat(body.cancelled.await(5, TimeUnit.SECONDS)).isTrue();
+
+ // A publisher may still signal an error that raced with the cancel. The request has already failed, so the
+ // late error must not be reported to the response handler a second time.
+ IllegalStateException lateError = new IllegalStateException("late publisher error");
+ body.error(lateError);
+ assertNoRequestSentAndConnectionStillUsable();
+ assertThat(handler.errors).noneMatch(e -> hasCause(e, lateError));
+ assertThat(result).isCancelled();
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("streamedRequestCases")
+ public void requestNotEligibleForEmptyFullRequest_isStreamed(String description,
+ Optional publisherLength,
+ Publisher body,
+ boolean fullDuplex,
+ Consumer customizer)
+ throws Exception {
+ resetAfterResponse = false;
+ RecordingHandler handler = new RecordingHandler();
+
+ SdkHttpFullRequest.Builder request = requestBuilder();
+ customizer.accept(request);
+ execute(request.build(), publisher(publisherLength, body), handler, fullDuplex).get(5, TimeUnit.SECONDS);
+
+ assertThat(requestHeadersEndStream).containsExactly(false);
+ assertThat(handler.errors).isEmpty();
+ }
+
+ private static Stream streamedRequestCases() {
+ Consumer noHeaders = r -> { };
+ Publisher empty = Flowable.just(ByteBuffer.allocate(0));
+ return Stream.of(
+ Arguments.of("unknown publisher length", Optional.empty(), empty, false, noHeaders),
+ Arguments.of("nonzero publisher length", Optional.of(3L), Flowable.just(ByteBuffer.wrap(new byte[3])), false,
+ noHeaders),
+ Arguments.of("full duplex", Optional.of(0L), empty, true, noHeaders),
+ Arguments.of("Expect: 100-continue", Optional.of(0L), empty, false,
+ header("Expect", "100-continue")),
+ Arguments.of("nonzero Content-Length header", Optional.of(0L), Flowable.just(ByteBuffer.wrap(new byte[3])),
+ false, header("Content-Length", "3")),
+ Arguments.of("Content-Length: 0 with Transfer-Encoding", Optional.of(0L), empty, false,
+ header("Content-Length", "0").andThen(header("Transfer-Encoding", "chunked"))),
+ Arguments.of("Transfer-Encoding only", Optional.of(0L), empty, false,
+ header("Transfer-Encoding", "chunked")));
+ }
+
+ @Test
+ public void http1EmptyBodyRequest_isNotAffected() throws Exception {
+ CopyOnWriteArrayList received = new CopyOnWriteArrayList<>();
+ CountDownLatch requestReceived = new CountDownLatch(1);
+ ServerSocketChannel http1Server = (ServerSocketChannel) new ServerBootstrap()
+ .channel(NioServerSocketChannel.class)
+ .group(serverGroup)
+ .childHandler(new ChannelInitializer() {
+ @Override
+ protected void initChannel(SocketChannel ch) {
+ ch.pipeline().addLast(new HttpServerCodec(), new HttpObjectAggregator(1024),
+ new ChannelInboundHandlerAdapter() {
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) {
+ FullHttpRequest request = (FullHttpRequest) msg;
+ received.add(request.retainedDuplicate());
+ requestReceived.countDown();
+ request.release();
+ FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
+ HttpResponseStatus.NOT_FOUND);
+ response.headers().set(HttpHeaderNames.CONTENT_LENGTH, 0);
+ ctx.writeAndFlush(response);
+ }
+ });
+ }
+ })
+ .localAddress(0)
+ .bind().await().channel();
+
+ try (SdkAsyncHttpClient http1Client = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP1_1).build()) {
+ RecordingHandler handler = new RecordingHandler();
+ SdkHttpFullRequest request = requestBuilder().port(http1Server.localAddress().getPort()).build();
+ http1Client.execute(AsyncExecuteRequest.builder()
+ .request(request)
+ .requestContentPublisher(publisher(Optional.of(0L),
+ Flowable.just(ByteBuffer.allocate(0))))
+ .responseHandler(handler)
+ .build())
+ .get(5, TimeUnit.SECONDS);
+
+ assertThat(requestReceived.await(5, TimeUnit.SECONDS)).isTrue();
+ assertThat(handler.responseComplete.await(5, TimeUnit.SECONDS)).isTrue();
+ assertThat(handler.statusCode).isEqualTo(404);
+ assertThat(handler.errors).isEmpty();
+ assertThat(received).hasSize(1);
+ assertThat(received.get(0).content().readableBytes()).isZero();
+ } finally {
+ received.forEach(ReferenceCountUtil::release);
+ http1Server.close().await();
+ }
+ }
+
+ private void assertNoRequestSentAndConnectionStillUsable() throws Exception {
+ // The client allows a single connection, so a follow-up request succeeding proves the cancelled request did
+ // not leave the connection broken. It is the only request the server sees.
+ execute(publisher(Optional.of(0L), Flowable.just(ByteBuffer.allocate(0))), new RecordingHandler())
+ .get(5, TimeUnit.SECONDS);
+ assertThat(requestHeadersEndStream).containsExactly(true);
+ }
+
+ private static boolean hasCause(Throwable t, Throwable cause) {
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ if (c == cause) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static Consumer header(String name, String value) {
+ return r -> r.putHeader(name, value);
+ }
+
+ private CompletableFuture execute(SdkHttpContentPublisher body, SdkAsyncHttpResponseHandler handler) {
+ return execute(requestBuilder().build(), body, handler, false);
+ }
+
+ private SdkHttpFullRequest.Builder requestBuilder() {
+ return SdkHttpFullRequest.builder()
+ .method(SdkHttpMethod.GET)
+ .protocol("http")
+ .host("localhost")
+ .port(serverChannel.localAddress().getPort());
+ }
+
+ private CompletableFuture execute(SdkHttpFullRequest request, SdkHttpContentPublisher body,
+ SdkAsyncHttpResponseHandler handler, boolean fullDuplex) {
+ return netty.execute(AsyncExecuteRequest.builder()
+ .request(request)
+ .requestContentPublisher(body)
+ .responseHandler(handler)
+ .fullDuplex(fullDuplex)
+ .build());
+ }
+
+ private static SdkHttpContentPublisher publisher(Optional contentLength, Publisher body) {
+ return new SdkHttpContentPublisher() {
+ @Override
+ public Optional contentLength() {
+ return contentLength;
+ }
+
+ @Override
+ public void subscribe(Subscriber super ByteBuffer> s) {
+ body.subscribe(s);
+ }
+ };
+ }
+
+ private ChannelFuture resetStream() {
+ Http2HeadersFrame request = lastRequestHeaders;
+ return lastServerContext.writeAndFlush(new DefaultHttp2ResetFrame(Http2Error.NO_ERROR).stream(request.stream()));
+ }
+
+ private static final class RecordingHandler implements SdkAsyncHttpResponseHandler {
+ private final List errors = new CopyOnWriteArrayList<>();
+ private final CountDownLatch responseComplete = new CountDownLatch(1);
+ private final CountDownLatch errored = new CountDownLatch(1);
+ private volatile int statusCode;
+
+ @Override
+ public void onHeaders(SdkHttpResponse headers) {
+ statusCode = headers.statusCode();
+ }
+
+ @Override
+ public void onStream(Publisher stream) {
+ Flowable.fromPublisher(stream).subscribe(b -> { }, errors::add, responseComplete::countDown);
+ }
+
+ @Override
+ public void onError(Throwable error) {
+ errors.add(error);
+ errored.countDown();
+ }
+ }
+
+ /**
+ * A request body that stays open, keeping the request write pending, until {@link #complete()} is called.
+ */
+ private static final class ControlledPublisher implements Publisher {
+ private final CountDownLatch subscribed = new CountDownLatch(1);
+ private final CountDownLatch cancelled = new CountDownLatch(1);
+ private volatile Subscriber super ByteBuffer> subscriber;
+
+ @Override
+ public void subscribe(Subscriber super ByteBuffer> s) {
+ subscriber = s;
+ s.onSubscribe(new Subscription() {
+ @Override
+ public void request(long n) {
+ }
+
+ @Override
+ public void cancel() {
+ cancelled.countDown();
+ }
+ });
+ subscribed.countDown();
+ }
+
+ void complete() {
+ subscriber.onComplete();
+ }
+
+ void error(Throwable t) {
+ subscriber.onError(t);
+ }
+ }
+
+ private class RespondThenResetHandler extends ChannelInboundHandlerAdapter {
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) {
+ try {
+ if (msg instanceof Http2HeadersFrame) {
+ Http2HeadersFrame requestHeaders = (Http2HeadersFrame) msg;
+ requestHeadersEndStream.add(requestHeaders.isEndStream());
+ lastServerContext = ctx;
+ lastRequestHeaders = requestHeaders;
+ ctx.write(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers().status("404"), true)
+ .stream(requestHeaders.stream()));
+ if (resetAfterResponse && !requestHeaders.isEndStream()) {
+ ctx.write(new DefaultHttp2ResetFrame(Http2Error.NO_ERROR).stream(requestHeaders.stream()));
+ }
+ ctx.flush();
+ serverResponded.countDown();
+ }
+ } finally {
+ ReferenceCountUtil.release(msg);
+ }
+ }
+ }
+}
diff --git a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapterTest.java b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapterTest.java
index b1ba94fa0329..aa7403f8cc41 100644
--- a/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapterTest.java
+++ b/http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/http2/HttpToHttp2OutboundAdapterTest.java
@@ -18,6 +18,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.netty.buffer.Unpooled;
@@ -30,6 +31,8 @@
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpVersion;
+import io.netty.handler.codec.http2.Http2DataFrame;
+import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.HttpConversionUtil;
import java.util.List;
import org.junit.AfterClass;
@@ -76,6 +79,51 @@ public void aggregatesWritePromises() {
assertThat(writePromise.isDone()).isTrue();
}
+ @Test
+ public void emptyFullRequest_writesSingleHeadersFrameWithEndStream() {
+ when(ctx.executor()).thenReturn(EVENT_LOOP_GROUP.next());
+ when(ctx.channel()).thenReturn(channel);
+
+ HttpToHttp2OutboundAdapter adapter = new HttpToHttp2OutboundAdapter();
+ ChannelPromise writePromise = new DefaultChannelPromise(channel, EVENT_LOOP_GROUP.next());
+
+ FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/", Unpooled.EMPTY_BUFFER);
+ request.headers().add(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), "http");
+ adapter.write(ctx, request, writePromise);
+
+ ArgumentCaptor