-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Migrate Writer APIs to Appendable parameter #2926
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No effect for normal usages.
This only applies to source compatibility. However, changing the parameter type breaks binary compatibility (the "Check API compatibility" CI workflow highlights this): Code which has been compiled against an older Gson version will still resolve against the methods and constructors with Writer parameter, and will therefore break when a newer Gson version with this change is used.
So it would be necessary to keep the existing methods and constructors with Writer parameter, and instead add additional ones taking an Appendable.
Personally I am not that convinced by this change. #2924 mentions as use case new JsonWriter(new StringBuilder)) but users could use a StringWriter instead of a StringBuilder.
And as mentioned above, having to keep the existing overloads with Writer would make the API then a bit verbose.
Maybe we should wait for more users to raise this issue, and see why the current API with Writer parameters is not suitable (and why implementing a custom Writer is not an option).
This is just my personal opinion on this though; I am not a direct member of this project.
Either way, thanks for this PR!
I understand your meaning. My |
Co-authored-by: Marcono1234 <[email protected]>
|
@Marcono1234 This is because the JsonWriter don't depend on Writer API. About the reason, |
|
I don't think the existing constructors and methods with
For this one, definitely create an issue first please to discuss this. Especially because there is no equivalent base interface (as it is the case for |
|
I think so. The |
Purpose
Currently some of APIs use Appendable as parameter and some other use Writer as parameter. This PR migrates all Writer parameters into Appendable. No effect for normal usages.
Description
closes #2924
Also adjusts some documentations.
Checklist
This is automatically checked by
mvn verify, but can also be checked on its own usingmvn spotless:check.Style violations can be fixed using
mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.null@since $next-version$(
$next-version$is a special placeholder which is automatically replaced during release)TestCase)mvn clean verify javadoc:jarpasses without errors