jakartaee / jakartaee/jsonp-api
Methods in Json re-create JsonProvider on each execution, Json should cache the result of JsonProvider.provider()
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 160
- Forks
- 64
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 4
Description
The methods in Json use `JsonProvider.provider()` and this **re-creates the JsonProvider on each execution**.
The javadoc for `JsonProvider.provider()` suggests that the caller should cache the resulting `JsonProvider` and `jakarta.json.Json` does not do this, so I think this is a bug.
For example, in Json we see:
```java
/**
* ...
*/
public static JsonParser createParser(Reader reader) {
return JsonProvider.provider().createParser(reader);
}
/**
* ...
*/
public static JsonParser createParser(InputStream in) {
return JsonProvider.provider().createParser(in);
}
```
In the javadoc for `JsonProvider.provider()` is says:
> _"Creates a JSON provider object. ... **Users are recommended to cache the result of this method**."_
I believe that means that `Json` should be changed to indeed cache the result of `JsonProvider.provider()`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Json class at the createParser(Reader) and createParser(InputStream) entry points, then inspect the other methods that call JsonProvider.provider(). Confirm the provider is cached as recommended by JsonProvider.provider() and that the Json methods use the cached result consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100