Skip to content

test(ses): parse the writer-overflow message on a stack of its own - #9097

Merged
pgermosen merged 1 commit into
mainfrom
test/ses-nested-mime-test-stack
Nov 20, 2026
Merged

pgermosen merged 1 commit into
mainfrom
test/ses-nested-mime-test-stack

Conversation

@hectorvent

@hectorvent hectorvent commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

SmtpRelayTest.relayRaw_nestingThatParsesButOverflowsTheWriter_isSkippedNotThrown, added in #9066, has failed on main and on most pull requests since it merged, with expected: not <null> at SmtpRelayTest.java:344. The test parses a message nested 10,000 message/rfc822 layers deep on the test thread and asserts the parse succeeds, then checks that the relay skips it when the writer overflows. Whether mime4j's recursive parser gets 10,000 layers deep depends on the stack of the thread it runs on, and on the CI runners the parse overflows first, so message() is null.

The test now parses that message on a thread with a 256 MB stack of its own, then relays it on the ordinary threads as before, where the writer must still overflow. SmtpRelay is unchanged.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

No behaviour change; test only.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository (maintainers and dependency bots are exempt).

Tests

Locally (macOS arm64), with SmtpRelayTest (52 tests) and SesMimeParserTest (3):

  • On main, the class passes with the default stack and fails with JAVA_TOOL_OPTIONS=-Xss512k or -Xss256k, with the same expected: not <null> as CI.
  • With this change, both classes pass with the default stack and with -Xss256k.

Checkstyle passes.

Pull requests to rebase onto main once this merges

Their latest CI run fails relayRaw_nestingThatParsesButOverflowsTheWriter_isSkippedNotThrown in a Build and Test shard. A rerun reuses the old merge with main, so each needs a rebase (or a merge of main) to pick this up:

relayRaw_nestingThatParsesButOverflowsTheWriter_isSkippedNotThrown parsed its 10,000-layer message on the test thread and asserted the parse succeeded, but whether mime4j's recursive parser gets that deep depends on the thread's stack. On CI runners it overflows first, so message() is null and the assertion fails: the test has failed on main and on most pull requests since #9066. It now parses on a thread with a 256 MB stack, then relays on the ordinary threads as before, where the writer must still overflow. With -Xss256k the old test fails with expected: not <null> and the new one passes.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
@hectorvent hectorvent added the ses Amazon Simple Email Service (SES) label Nov 20, 2026
@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Stabilize SES writer-overflow test with a dedicated parse stack

🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Parse deeply nested MIME on a dedicated large-stack thread to avoid CI stack-dependent failures.
• Keep relay execution on ordinary threads so the test still verifies writer-overflow handling.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • No production behavior changes identified.
Behavioral complexity 🟢 Low 🧩 Assessed behavior

  • No production behavior changes identified.
Potential damage 🟢 Low 🩹 Assessed behavior

  • No production behavior changes identified.
Assessed commit c5b931e
Diagram

sequenceDiagram
    actor Test
    participant Fixture as NestedMime
    participant ParseThread as Parse thread
    participant Parser as MIME parser
    participant Relay as SmtpRelay
    participant Worker as Relay worker
    participant Client as MailClient
    Test->>Fixture: Build nested MIME
    Fixture-->>Test: Raw message
    Test->>ParseThread: Start with large stack
    ParseThread->>Parser: Parse raw message
    Parser-->>ParseThread: Parsed message
    ParseThread-->>Test: Return after join
    Test->>Relay: Relay parsed message
    Relay->>Worker: Process on ordinary stack
    Note over Worker: Writer overflows; relay skips message
    Test->>Client: Verify no send
Loading
High-Level Assessment

Keep the dedicated parse thread: it isolates the parser's stack requirement without changing the relay or masking the writer overflow. Increasing the JVM-wide stack would also enlarge the relay worker's stack and undermine the test.

Files changed (1) +21 / -2

Tests (1) +21 / -2
SmtpRelayTest.javaParse the writer-overflow fixture on a large-stack thread +21/-2

Parse the writer-overflow fixture on a large-stack thread

• Adds a helper that constructs the parsed raw relay message on a thread with a 256 MB stack and joins it before returning. The writer-overflow test uses that helper while retaining its assertions that parsing succeeds and relay sends nothing.

src/test/java/io/floci/aws/services/ses/SmtpRelayTest.java

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hectorvent thanks, this gets at the real cause. The 10,000-layer message is now parsed on a thread with its own 256 MB stack, so assertNotNull(nested.message()) no longer depends on how much stack the test thread happens to have.

The relay itself still runs on the test thread through the synchronous test executor, so what the test checks is unchanged: the writer overflows, doRelayRaw catches the StackOverflowError, and nothing is sent. SmtpRelay is untouched.

@pgermosen
pgermosen merged commit 2402267 into main Nov 20, 2026
31 of 33 checks passed
@pgermosen
pgermosen deleted the test/ses-nested-mime-test-stack branch November 20, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ses Amazon Simple Email Service (SES)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants