Skip to content
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

Change parent type of JsonProcessingException to be RuntimeException #2177

Closed
cowtowncoder opened this issue Nov 7, 2018 · 4 comments
Closed
Labels
3.x most-wanted Tag to indicate that there is heavy user +1'ing action
Milestone

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented Nov 7, 2018

(NOTE: part of bigger set of changes, see https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-4)

Although choice of JsonProcessingException to extend IOException made sense originally (I think), later developments -- in particular, Java 8 Streams and functional approach in general -- have made use of checked exceptions cumbersome for many use cases.
But due to backwards compatibility concerns, change of base exception type has not been possible within 2.x releases.

Now that we are working on 3.0, however, we can make this change. Compared to alternative of providing alternate subtypes of ObjectMapper, ObjectReader and/or ObjectWriter (ones that do not declare checked exceptions for methods), this leads to simpler API.
For 2.x we may still consider simpler work-arounds (maybe convenience wrappers), but with 3.0 let's rebase.

Note, too, that this will help use of Jackson for some specific cases like serialization of this from toString() (and with #2176).

@cowtowncoder
Copy link
Member Author

Note: actual change is being done via jackson-core, as:

FasterXML/jackson-core#661

and I have a branch with mostly complete changes. However, coordination with all modules is required so while this effort is finally active again, it may take a week or two.

@cowtowncoder
Copy link
Member Author

A lot of work done, on exp/jstep-4-for-3.0 branches of:

  • jackson-core, jackson-databind (core packages; annotations not affected)
  • All dataformats (jackson-dataformats-binary, jackson-dataformats-text, jackson-dataformat-xml)
  • jackson-jr
  • Some datatypes (jackson-datatypes-collections, jackson-datatype-joda)
  • Main modules (jackson-modules-base, jackson-modules-java8)

and just sent an email to jackson-dev.

Next steps:

  • Continue work on modules (jackson-datatypes-misc, jackson-jaxrs-providers, especially)
  • Coordinate with Kotlin and Scala module authors

and planning on merging the changes tomorrow, January 19th 2021, if all goes well.

cowtowncoder added a commit that referenced this issue Jan 20, 2021
Make changes resulting from jackson-core/661 (change `JacksonException` to extend `RuntimeException`), mostly signature changes.
@cowtowncoder
Copy link
Member Author

The core change has been completed; continuing with related clean up.

Noteworthy related changes:

  • Addition of replacement exception types:
    • JsonProcessingException -> JacksonException (added in 2.12)
    • JsonParseException -> StreamReadException (added in 2.10)
    • JsonGenerationException -> StreamWriteException (added in 2.13)
    • JsonMappingException -> DatabindException (added in 2.13)

In all of above cases the new exception type -- planned to replace original one in 3.0 -- will be new super-class so that:

  1. Code that catches exceptions CAN (and eventually SHOULD) start using it, even in 2.x (since existing code that throws either old or new type would still be compatible)
  2. Code that throws exceptions CANNOT start replacing type since existing code that catches old exceptions would not catch new type

To prevent (2), new types are added as abstract types in 2.x and become concrete only in 3.0.

@cowtowncoder cowtowncoder added this to the 3.0.0 milestone Jan 29, 2021
@cowtowncoder
Copy link
Member Author

Completed; may work on demoting some aspects of DatabindException (logical location) down to JacksonException but there's separate issue for that already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x most-wanted Tag to indicate that there is heavy user +1'ing action
Projects
None yet
Development

No branches or pull requests

1 participant