-
Notifications
You must be signed in to change notification settings - Fork 95
Jackson 3 migration #536
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
Open
fatroom
wants to merge
13
commits into
zalando:main
Choose a base branch
from
fatroom:jackson3_migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Jackson 3 migration #536
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
11d37dc
Jackson 3 migration
fatroom c1ae561
Added proper versioning of the jackson module
fatroom e6747d5
Update build to use JDK17
fatroom 592a3ad
EOL correction
fatroom a705ebf
README update with jackson 3 references
fatroom eeeca4a
Restored jackson2 and introduced jackson3 artifacts
fatroom aebe836
Updated MAINTAINERS list
fatroom a0dde47
Updated README with note about JPMS
fatroom 0444682
Used newer maven plugin versions
fatroom 0c60ed6
Set version to 1.0.0-SNAPSHOT
fatroom 6e395b5
[lint] EOL changes
fatroom 4944c66
Corrected API status declaration
fatroom 4a7897d
Updated README with spring specific implementation hints
fatroom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| * @whiskeysierra @lukasniemeier-zalando | ||
| * @lukasniemeier-zalando @fatroom |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1.8 | ||
| 17 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip | ||
| wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip | ||
| wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Willi Schönborn <w.schoenborn@gmail.com> | ||
| Lukas Niemeier <lukas.niemeier@zalando.de> | ||
| Roman Romanchuk <roman.romanchuk+opensource@zalando.de> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
|
|
||
| *Problem* is a library that implements | ||
| [`application/problem+json`](https://tools.ietf.org/html/rfc7807). | ||
| It comes with an extensible set of interfaces/implementations as well as convenient functions for every day use. | ||
| It comes with an extensible set of interfaces/implementations as well as convenient functions for everyday use. | ||
| It's decoupled from any JSON library, but contains a separate module for Jackson. | ||
|
|
||
| ## Features | ||
|
|
@@ -25,9 +25,10 @@ It's decoupled from any JSON library, but contains a separate module for Jackson | |
|
|
||
| ## Dependencies | ||
|
|
||
| - Java 8 | ||
| - Java 17 | ||
| - Any build tool using Maven Central, or direct download | ||
| - Jackson (optional) | ||
| - Jackson2 (optional) | ||
| - Jackson3 (optional) | ||
| - Gson (optional) | ||
|
|
||
| ## Installation | ||
|
|
@@ -42,7 +43,7 @@ Add the following dependency to your project: | |
| </dependency> | ||
| <dependency> | ||
| <groupId>org.zalando</groupId> | ||
| <artifactId>jackson-datatype-problem</artifactId> | ||
| <artifactId>problem-jackson3</artifactId> | ||
| <version>${problem.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
|
|
@@ -54,7 +55,7 @@ Add the following dependency to your project: | |
|
|
||
| ### Java Modules | ||
|
|
||
| Even though the minimum requirement is still Java 8, all modules are Java 9 compatible: | ||
| All modules are fully compatible with the Java Platform Module System (JPMS): | ||
|
|
||
| ```java | ||
| module org.example { | ||
|
|
@@ -67,18 +68,16 @@ module org.example { | |
|
|
||
| ## Configuration | ||
|
|
||
| In case you're using Jackson, make sure you register the module with your `ObjectMapper`: | ||
| In case you're using Jackson, make sure you register the module with your `JsonMapper`: | ||
|
|
||
| ```java | ||
| ObjectMapper mapper = new ObjectMapper() | ||
| .registerModule(new ProblemModule()); | ||
| JsonMapper mapper = JsonMapper.builder().addModule(new ProblemModule()).build(); | ||
| ``` | ||
|
|
||
| Alternatively, you can use the SPI capabilities: | ||
|
|
||
| ```java | ||
| ObjectMapper mapper = new ObjectMapper() | ||
| .findAndRegisterModules(); | ||
| JsonMapper mapper = JsonMapper.builder().findAndAddModules().build(); | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
@@ -95,7 +94,7 @@ enough to convey the necessary information. Everything you need is the status yo | |
| create a problem from it: | ||
|
|
||
| ```java | ||
| Problem.valueOf(Status.NOT_FOUND); | ||
| var problem = Problem.valueOf(Status.NOT_FOUND); | ||
| ``` | ||
|
|
||
| Will produce this: | ||
|
|
@@ -121,7 +120,7 @@ As specified by [Predefined Problem Types](https://tools.ietf.org/html/rfc7807#s | |
| But you may also have the need to add some little hint, e.g. as a custom detail of the problem: | ||
|
|
||
| ```java | ||
| Problem.valueOf(Status.SERVICE_UNAVAILABLE, "Database not reachable"); | ||
| var problem = Problem.valueOf(Status.SERVICE_UNAVAILABLE, "Database not reachable"); | ||
| ``` | ||
|
|
||
| Will produce this: | ||
|
|
@@ -141,7 +140,7 @@ construct problems in a more flexible way. This is where the *Problem Builder* c | |
| and allows to construct problem instances without the need to create custom classes: | ||
|
|
||
| ```java | ||
| Problem.builder() | ||
| var problem = Problem.builder() | ||
| .withType(URI.create("https://example.org/out-of-stock")) | ||
| .withTitle("Out of Stock") | ||
| .withStatus(BAD_REQUEST) | ||
|
|
@@ -163,7 +162,7 @@ Will produce this: | |
| Alternatively you can add custom properties, i.e. others than `type`, `title`, `status`, `detail` and `instance`: | ||
|
|
||
| ```java | ||
| Problem.builder() | ||
| var problem = Problem.builder() | ||
| .withType(URI.create("https://example.org/out-of-stock")) | ||
| .withTitle("Out of Stock") | ||
| .withStatus(BAD_REQUEST) | ||
|
|
@@ -211,7 +210,7 @@ public final class OutOfStockProblem extends AbstractThrowableProblem { | |
| ``` | ||
|
|
||
| ```java | ||
| new OutOfStockProblem("B00027Y5QG"); | ||
| var problem = new OutOfStockProblem("B00027Y5QG"); | ||
| ``` | ||
|
|
||
| Will produce this: | ||
|
|
@@ -263,7 +262,7 @@ Jackson module makes heavy use of it. Considering you have a custom problem type | |
| register it as a subtype: | ||
|
|
||
| ```java | ||
| mapper.registerSubtypes(OutOfStockProblem.class); | ||
| mapper.builder().registerSubtypes(OutOfStockProblem.class); | ||
| ``` | ||
| You also need to make sure you assign a `@JsonTypeName` to it and declare a `@JsonCreator`: | ||
|
|
||
|
|
@@ -276,7 +275,7 @@ public final class OutOfStockProblem implements Problem { | |
| ``` | ||
|
|
||
| Jackson is now able to deserialize specific problems into their respective types. By default, e.g. if a type is not | ||
| associated with a class, it will fallback to a `DefaultProblem`. | ||
| associated with a class, it will fall back to a `DefaultProblem`. | ||
|
|
||
| ### Catching problems | ||
|
|
||
|
|
@@ -344,12 +343,13 @@ Will produce this: | |
|
|
||
| Another important aspect of exceptions are stack traces, but since they leak implementation details to the outside world, | ||
| [**we strongly advise against exposing them**](http://zalando.github.io/restful-api-guidelines/#177) | ||
| in problems. That being said, there is a legitimate use case when you're debugging an issue on an integration environment | ||
| in problems. That being said, there is a legitimate use case when you're debugging an issue on an integration environment, | ||
| and you don't have direct access to the log files. Serialization of stack traces can be enabled on the problem module: | ||
|
|
||
| ```java | ||
| ObjectMapper mapper = new ObjectMapper() | ||
| .registerModule(new ProblemModule().withStackTraces()); | ||
| JsonMapper mapper = JsonMapper.builder() | ||
| .addModule(new ProblemModule().withStackTraces()) | ||
| .build(); | ||
| ``` | ||
|
|
||
| After enabling stack traces all problems will contain a `stacktrace` property: | ||
|
|
@@ -381,7 +381,7 @@ public interface StackTraceProcessor { | |
| } | ||
| ``` | ||
|
|
||
| By default no processing takes place. | ||
| By default, no processing takes place. | ||
|
|
||
| ## Getting help | ||
|
|
||
|
|
@@ -396,11 +396,11 @@ For more details check the [contribution guidelines](.github/CONTRIBUTING.md). | |
|
|
||
| ### Spring Framework | ||
|
|
||
| Users of the [Spring Framework](https://spring.io) are highly encouraged to check out [Problems for Spring Web MVC](https://github.com/zalando/problem-spring-web), a library that seemlessly integrates problems into Spring. | ||
| Users of the [Spring Framework](https://spring.io) are highly encouraged to check out [Problems for Spring Web MVC](https://github.com/zalando/problem-spring-web), a library that seamlessly integrates problems into Spring. | ||
|
||
|
|
||
| ### Micronaut Framework | ||
| Users of the [Micronaut Framework](https://micronaut.io) are highly encouraged to check out [Micronaut Problem JSON | ||
| ](https://micronaut-projects.github.io/micronaut-problem-json/snapshot/guide/), a library that seemlessly integrates problems into Micronaut error processing. | ||
| ](https://micronaut-projects.github.io/micronaut-problem-json/snapshot/guide/), a library that seamlessly integrates problems into Micronaut error processing. | ||
|
|
||
| ### Quarkus Framework | ||
| Users of the [Quarkus Framework](https://quarkus.io/) are highly encouraged to check out [Quarkus RESTeasy Problem Extension](https://github.com/TietoEVRY/quarkus-resteasy-problem/), a library that seemlessly integrates problems into Quarkus RESTeasy/JaxRS error processing. It also handles Problem-family exceptions from `org.zalando:problem` library. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Do we need to break compatibility with older Java software to support Jackson 3?
If we cannot release without this Java version update, we should increase the major version number in this release to clearly mark that it is breaking backward compatibility.
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.
Jackson 3 build with JDK17, older JDK will not be able to read classes, so yep, we need this.
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.
Regarding versioning - set version to 1.0.0-SNAPSHOT