Skip to content

Bugfix/5589 DynamoDB immutable getters introspection for underscores and dollar sign issue - #7510

Open
iulianbudau wants to merge 2 commits into
aws:masterfrom
iulianbudau:bugfix/5589-dynamoDbImmutable-underscores-issue
Open

iulianbudau wants to merge 2 commits into
aws:masterfrom
iulianbudau:bugfix/5589-dynamoDbImmutable-underscores-issue

Conversation

@iulianbudau

Copy link
Copy Markdown
Contributor

Motivation and Context

TableSchema.fromClass / immutable schema creation fails for Lombok-style @DynamoDbImmutable models when a field such as __encryption_keyId produces getter get__encryption_keyId() and fluent builder __encryption_keyId(...). ImmutableIntrospector only stripped a get prefix when the next character was uppercase, so the property key stayed get__encryption_keyId and did not match the builder. The equivalent @DynamoDbBean path already maps the attribute as __encryption_keyId via JavaBeans introspection.
Fixes #5589.

Modifications

  • In ImmutableIntrospector.normalizeGetterName, the get branch also strips when the character after get is _ or $, preserving existing lowercasing/suffix behavior (getId → id, getURL → uRL, getfoo → getfoo).
  • Prefer a valid builder match on the normalized name; for get_ / get$ getters only, fall back to the original getter name if no valid normalized builder exists (legacy pairing). Ordinary getX / isX stripping does not use that fallback.
  • normalizeSetterName, the is branch, discovery, ignore/transient handling, and unmatched/leftover validation behavior are unchanged aside from using the resolved property name.
  • Tests (handwritten models; no Lombok dependency): introspector coverage for normalized/legacy _ and $, ambiguous both-builders, and getURL/getfoo; schema round-trips via itemToMap / mapToItem plus a @DynamoDbBean control for attribute __encryption_keyId.

Testing

Tests added

  • Updates to ImmutableIntrospectorTest
  • New ImmutableLeadingUnderscoreAttributeTest (normalized/legacy _ and $ schema round-trips; bean control)
  • Tests executed and passed locally

Test Coverage Matrix

Scenario Done Comments if Not Done
1. Different TableSchema Creation Methods
a. TableSchema.fromBean(Customer.class) [x] Bean control via TableSchema.fromBean(UnderscoreBean.class) in ImmutableLeadingUnderscoreAttributeTest; focused + module tests passed.
b. TableSchema.fromImmutableClass(Customer.class) for immutable classes [ ] Immutable cases used TableSchema.fromClass (same immutable introspection path); fromImmutableClass not invoked explicitly.
c. TableSchema.documentSchemaBuilder().build() [ ] Not applicable to this immutable getter-normalization fix.
d. StaticTableSchema.builder(Customer.class) [ ] Not applicable; static schemas do not use ImmutableIntrospector naming.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@iulianbudau
iulianbudau requested a review from a team as a code owner November 4, 2026 09:40

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fields with underscores work with @DynamoDbBean but not with @DynamoDbImmutable

2 participants