Introspected POJO which uses Jackson JsonInclude.Include.NON_NULL) does not work with GraalVM #2933
Labels
relates-to: graal
relates-to: jackson
status: pr submitted
A pull request has been submitted for the issue
type: bug
Something isn't working
Milestone
Steps to reproduce
Generate a JAR with an introspected POJO and Jackson annotations
Generate a JAR with an introspected POJO:
Create a POJO
pojojar % mkdir -p src/main/java/example/micronaut/pojos
pojojar % touch src/main/java/example/micronaut/pojos/Book.java
It uses
@JsonInclude(JsonInclude.Include.NON_NULL)
to specify thatauthor
field should be included in a serialised response only when populated.Generate a JAR file
pojojar % ./gradlew assemble
Create a Micronaut App with GraalVM feature which uses the JAR
Modify the build file generated by Micronaut CLI. Add in the dependencies block the next line:
Create a Controller which returns the POJO in the JAR.
Create a controller
src/main/java/hello/world/BookController.java
Generate a FAT JAR
Executing the FAT JAR works with Jackson annotation
Jackson annotation
@JsonInclude(JsonInclude.Include.NON_NULL)
works as expected. Non null fields are not included:Generate a Native Image
Calling the controller returns a POJO which includes non-null fields.
Versions
Micronaut version: 1.3.3
JDK Version: 1.8
GraalVM Version: 20.0.0-java8
The text was updated successfully, but these errors were encountered: