Skip to content

Conversation

@nitishagar
Copy link

What was changed

Modified ActivityOptions.Builder.mergeActivityOptions() to create a new ArrayList when combining context propagators instead of calling addAll() directly on the existing list. Added a test to verify the fix.

Files changed:

  • temporal-sdk/src/main/java/io/temporal/activity/ActivityOptions.java
  • temporal-sdk/src/test/java/io/temporal/activity/ActivityOptionsTest.java

Why?

When users set context propagators using immutable lists (e.g., List.of() or Collections.emptyList()), merging ActivityOptions would throw UnsupportedOperationException because the code attempted to call addAll() on an immutable list.

This fix follows the approach suggested by @cretz in the issue: create a new list that combines both instead of modifying one of them.

Checklist

  1. Closes Merging ActivityOptions fails with UnsupportedOperationException when using immutable lists for context propagators #2482

  2. How was this tested:

    • Added unit test testActivityOptionsMergeWithImmutableContextPropagators that creates two ActivityOptions with immutable context propagator lists (Collections.emptyList()) and verifies they can be merged without throwing UnsupportedOperationException
    • All existing ActivityOptionsTest tests pass
    • Full build passes (./gradlew clean build)
  3. Any docs updates needed?

    • No documentation updates needed - this is a bug fix with no API changes

…mmutable context propagators

The mergeActivityOptions method was calling addAll() directly on the existing
contextPropagators list, which fails when the list is immutable (e.g., created
with List.of() or Collections.emptyList()).

This fix creates a new ArrayList that combines both lists instead of modifying
the existing one.

Fixes temporalio#2482
@nitishagar nitishagar requested a review from a team as a code owner December 26, 2025 09:01
@CLAassistant
Copy link

CLAassistant commented Dec 26, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merging ActivityOptions fails with UnsupportedOperationException when using immutable lists for context propagators

2 participants