Skip to content

return default instance on unchanged builder #365

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
merged 2 commits into from
Apr 22, 2025

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Apr 22, 2025

I can't see a reason to return separate instances.

Essentially this change causes the same Jsonb instance to be returned by the statement Jsonb.builder().build()

I can't see a reason to return separate instances
@SentryMan SentryMan added the enhancement New feature or request label Apr 22, 2025
@SentryMan SentryMan added this to the 3.4 milestone Apr 22, 2025
@SentryMan SentryMan self-assigned this Apr 22, 2025
@SentryMan SentryMan enabled auto-merge April 22, 2025 02:32
@rbygrave
Copy link
Contributor

I see this as a performance optimisation, but I don't see it being a very commonly used one because factories is generally not empty, so I see as a not very useful performance optimisation?

What was a motivation for this?

@SentryMan
Copy link
Collaborator Author

For Jsonb, there are a bunch of places where a default jsonb instance can get created. (inject plugin, jex default adapter, http-client default adapter)

I've also got some internal libraries that create default jsonb instances via SPI

@SentryMan
Copy link
Collaborator Author

factories is generally not empty

If there are no manually provided factories, it will be empty by the time the check happens. Otherwise that test I added would fail

@SentryMan SentryMan merged commit 5ac2eae into avaje:main Apr 22, 2025
5 checks passed
@SentryMan SentryMan deleted the default-instance branch April 22, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants