Skip to content

feat(6418): EnhancedDynamoDB#AutoGeneratedUuidExtension with supplier UUID - #6422

Closed
marcusvoltolim wants to merge 1 commit into
aws:masterfrom
marcusvoltolim:feature-6418/auto-generated-uuid-extension-custom-supplier-uuid
Closed

marcusvoltolim wants to merge 1 commit into
aws:masterfrom
marcusvoltolim:feature-6418/auto-generated-uuid-extension-custom-supplier-uuid

Conversation

@marcusvoltolim

@marcusvoltolim marcusvoltolim commented Sep 15, 2025 •

Copy link
Copy Markdown

Resolves #6418

  • Introduced a customizable uuidSupplier in AutoGeneratedUuidExtension with default UUID.randomUUID() functionality.
  • Added a builder pattern to create extensions with custom suppliers.
  • Enhanced tests to validate the custom UUID supplier functionality and maintain backward compatibility.
  • Refactoring all tests and add more scenarios;
  • Fixing AutoGeneratedUuidExtension`s JavaDoc

Motivation and Context

Possibility of working with other versions of UUID such as v7 which is based on TimeStamp, facilitating the ordering of records by UUID.

Modifications

Adding Supplier and Builder in AutoGeneratedUuidExtension

Testing

Tested the 2 scenarios with standard supplier that uses UUID.randomUUID() and the new scenario setting a supplier that generates UUIDv7, validating the UUID version.

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

@marcusvoltolim
marcusvoltolim requested a review from a team as a code owner September 15, 2025 22:10
@marcusvoltolim marcusvoltolim changed the title feat(6418): Add customizable UUID supplier in AutoGeneratedUuidExtension feat(6418): AutoGeneratedUuidExtension refactoring to accept UUID supplier Sep 15, 2025
@marcusvoltolim marcusvoltolim changed the title feat(6418): AutoGeneratedUuidExtension refactoring to accept UUID supplier feat(6418): Refactor **AutoGeneratedUuidExtension** to accept UUID supplier Sep 15, 2025
@marcusvoltolim marcusvoltolim changed the title feat(6418): Refactor **AutoGeneratedUuidExtension** to accept UUID supplier feat(6418): Refactor *AutoGeneratedUuidExtension* to accept UUID supplier Sep 15, 2025
@marcusvoltolim marcusvoltolim changed the title feat(6418): Refactor *AutoGeneratedUuidExtension* to accept UUID supplier feat(6418): Refactor AutoGeneratedUuidExtension to accept UUID supplier Sep 15, 2025
@marcusvoltolim marcusvoltolim changed the title feat(6418): Refactor AutoGeneratedUuidExtension to accept UUID supplier feat(6418): EnhancedDynamoDB#AutoGeneratedUuidExtension with supplier UUID Sep 15, 2025
@marcusvoltolim
marcusvoltolim force-pushed the feature-6418/auto-generated-uuid-extension-custom-supplier-uuid branch from bae19b0 to 34fcc4e Compare September 15, 2025 23:57
- Introduced a customizable `uuidSupplier` in `AutoGeneratedUuidExtension` with default `UUID.randomUUID()` functionality.
- Added a builder pattern to create extensions with custom suppliers.
- Enhanced tests to validate the custom UUID supplier functionality and maintain backward compatibility.
- Refactoring all tests and add more scenarios;
- Fixing AutoGeneratedUuidExtension`s JavaDoc
@marcusvoltolim
marcusvoltolim force-pushed the feature-6418/auto-generated-uuid-extension-custom-supplier-uuid branch from 34fcc4e to 79c6d17 Compare September 16, 2025 14:17
@debora-ito
debora-ito requested a review from alextwoods August 21, 2026 21:01

@alextwoods alextwoods left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR needs to be rebased before I can run CI on it, looks like its based on a pretty out of date commit.

{
"type": "feature",
"category": "AWS DynamoDB Enhanced Client",
"description": "Refactoring `AutoGeneratedUuidExtension` to accepted UUID supplier to make possible using other UUID versions.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The description has some grammer mistakes and describes implementation rather than the customer feature. Maybe something like:

Suggested change
"description": "Refactoring `AutoGeneratedUuidExtension` to accepted UUID supplier to make possible using other UUID versions.",
"description": "Added AutoGeneratedUuidExtension.builder().uuidSupplier(Supplier<UUID>) so applications can plug in an alternative UUID generator, for example a time-ordered UUIDv7. The default remains UUID.randomUUID()."

<type>so</type>
<scope>test</scope>
</dependency>
<dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we should be introducing a new test dependency here - as far as I can tell this is only used in the tests to verify that the uuid prodcued actually came from our supplier. I've left a comment on that test as well, but I think we should provide our own deterministic supplier instead which will strengthen that test and eliminate this dependency.

* DynamoDbEnhancedClient.builder().extensions(Stream.concat(ExtensionResolver.defaultExtensions().stream(),
* Stream.of(AutoGeneratedUuidExtension.create())).collect(Collectors.toList())).build();
*}
* {@code DynamoDbEnhancedClient.builder().extensions(Stream.concat(ExtensionResolver.defaultExtensions().stream(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did we change these from @snippet to @code? I think @snippet is a pretty common pattern across this code. Was there some documentation rendering issue you were trying to fix?

* Stream.of(AutoGeneratedUuidExtension.create())).collect(Collectors.toList())).build();
*}
* {@code DynamoDbEnhancedClient.builder().extensions(Stream.concat(ExtensionResolver.defaultExtensions().stream(),
* Stream.of(AutoGeneratedUuidExtension.create())).collect(Collectors.toList())).build();}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there may be an unbalanced paren starting in the line above this one: ...extensions(AutoGeneratedUuidExtension.create())).build(); — one ) too many (if I counted right. Might have mis-read).

* This extension facilitates the automatic generation of a unique UUID (Universally Unique Identifier) for a specified attribute
* every time a new record is written to the database. The generated UUID is obtained using the
* {@link java.util.UUID#randomUUID()} method.
* {@link java.util.UUID#randomUUID()} method by default or a custom UUID supplier instance provided by the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets add a paragraph documenting (with snippet) the new builder().uuidSupplier(...) entry point — it is currently invisible in the class Javadoc.

}

/**
* Sets the UUID supplier instance , else {@link UUID#randomUUID()} is used by default. Every time a new UUID is generated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extra space before comma


/**
* Sets the UUID supplier instance , else {@link UUID#randomUUID()} is used by default. Every time a new UUID is generated
* this supplier will be used to get the current UUID. If a custom supplier is not specified, the default randomUUID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doc nit pick: "Current UUID" doesn't really make sense (I assume this wording was copied).

how about something like:

"Sets the supplier used to generate UUID values. Defaults to UUID::randomUUID. Invoked once per auto-generated attribute on every write; must be thread-safe and must not return null."

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like we're mixing some different assertion libraries - if possible would probably be better to be consistent

DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName());

private final AutoGeneratedUuidExtension atomicCounterExtension = AutoGeneratedUuidExtension.create();
class AutoGeneratedUuidExtensionTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per the AutoGeneratedTimestamp-regression-analysis checklist, a change to an extension must be exercised against all four TableSchema creation methods and on both sync and async tables, plus the shared-client supported/unsupported matrix. This PR covers StaticTableSchema and bean-via-fromClass only. I think the async gap is the one that matters most for this specific change since the extension instance is now stateful (it holds a supplier) and is shared across concurrent async writes, so async is exactly where a non-thread-safe or misbehaving supplier surfaces.


}
private void assertUUIDv7(String uuid) {
assertEquals(7, UUID.fromString(uuid).version());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mentioned in comments in the pom.xml as well - I don't think this is actually a useful test because this is an indirect proxy for the property under test, which is "the supplier I injected was the one that produced the stored value" (any other incorrect uuid7 supplier that somehow ended up getting used would still pass this test) - We should be able to use a more deterministic custom supplier.

@debora-ito

Copy link
Copy Markdown
Member

@marcusvoltolim let us know if you are still interested in working on this PR.

@debora-ito debora-ito added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Sep 3, 2026
@github-actions

Copy link
Copy Markdown

It looks like this PR has not been active for more than five days. In the absence of more information, we will be closing this PR soon. Please add a comment to prevent automatic closure, or if the PR is already closed please feel free to open a new one.

@github-actions github-actions Bot added the closing-soon This issue will close in 4 days unless further comments are made. label Sep 14, 2026
@alextwoods

Copy link
Copy Markdown
Contributor

Feature was released in: #6373

@alextwoods alextwoods closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon This issue will close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EnhancedDynamoDB#AutoGeneratedUuidExtension with supplier UUID

3 participants