Skip to content

Handle null when serializing enum to string #6342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

RanVaknin
Copy link
Contributor

Motivation and Context

#3861

Modifications

Updated MemberCopierSpec.java to generate a null check before calling `entry.toString() when serializing enums to strings.

Testing

  • Updated codegen fixture files with the expected code generated content
  • Added a unit test to verify that null enum doesn't throw NPE.

@RanVaknin RanVaknin requested a review from a team as a code owner August 13, 2025 20:26
@RanVaknin RanVaknin added changelog-not-required Indicate changelog entry is not required for a specific PR no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required labels Aug 13, 2025
@RanVaknin
Copy link
Contributor Author

Flakey integ test failure S3TransferManagerDownloadPauseResumeIntegrationTest , should be safe to merge.

@zoewangg
Copy link
Contributor

Can we add a changelog entry? Changelog entry is not required only for house keeping changes such as test code or README update

@zoewangg zoewangg removed the changelog-not-required Indicate changelog entry is not required for a specific PR label Aug 15, 2025
@joviegas
Copy link
Contributor

Can we add a test case in the protocol test , may be src/main/resources/software/amazon/awssdk/protocol/suites/cases/json-core-input.json ?
something like

{
  "description": "List of enums with null values are marshalled correctly without NPE",
  "given": {
    "input": {
      "ListOfEnums": [
        "EnumValue1",
        null,
        "EnumValue2"
      ]
    }
  },
  "when": {
    "action": "marshall",
    "operation": "AllTypes"
  },
  "then": {
    "serializedAs": {
      "body": {
        "jsonEquals": "{\"ListOfEnums\": [\"EnumValue1\", null, \"EnumValue2\"]}"
      }
    }
  }
}

same for maps so we know what we are sending on the wire

Copy link

@RanVaknin RanVaknin added this pull request to the merge queue Aug 19, 2025
Merged via the queue into master with commit 4dab0c3 Aug 19, 2025
38 checks passed
Copy link

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants