#12362 factory method for jso nbuilders#12541
Draft
TillJan wants to merge 6 commits into
Draft
Conversation
poikilotherm
requested changes
Jul 17, 2026
| @@ -1,5 +1,6 @@ | |||
| package edu.harvard.iq.dataverse.api.errorhandlers; | |||
|
|
|||
| import edu.harvard.iq.dataverse.util.json.JsonUtil; | |||
| import jakarta.json.Json; | |||
Contributor
There was a problem hiding this comment.
Can we try deleting all the jakarta.json.Json imports in all the affected class files? People really should no longer use it for object or array builders.
I would be curious if there are any other usages. Ideally, we would make the build fail if someone uses these functions, as avoiding them in the future would eliminate the performance problem.
use JsonUtil.createObjectBuilder and JsonUtil.createArrayBuilder to reuse JsonUtil.builderFactory and avoid inefficient usage of JSON providers/builders.
TillJan
force-pushed
the
#12362-factory-method-for-JSONbuilders
branch
from
July 17, 2026 12:13
bff606e to
04f565f
Compare
added 2 commits
July 17, 2026 14:39
refactored the start import to specific imports
replaced all Json.createObjectBuilder() and Json.createArrayBuilder() calls with the matching JsonUtil methods.
TillJan
force-pushed
the
#12362-factory-method-for-JSONbuilders
branch
from
July 17, 2026 12:45
04f565f to
ac66224
Compare
For now, enable less invasive bundled checks. In addition, adding first rules to disallow usage of JSON-P Json.createX() API.
Disallow more methods for object and array builders using copy-style arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
The PR adds methods in the JsonUtil for creating a JsonObjectBuilder and a JsonArrayBuilder. JsonUtil caches a JsonBuilderFactory which is shared by both methods.
All usage of Json.createArrayBuilder() and Json.createObjectBuilder has been replaced by the new methods.
This avoids repeatedly loading a Jakarta JSON-P implementation through the ServiceLoader which caused inefficiency.
Which issue(s) this PR closes:
Special notes for your reviewer:
The JsonBuilderFactory is shared and only created one time, while the methods are returning new Builder everytime.
Suggestions on how to test this:
run existing tests
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
no
Is there a release notes update needed for this change?:
no
Additional documentation: