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

java.time.DateTimeException serialization fails #319

Closed
olibraga opened this issue Sep 27, 2024 · 3 comments
Closed

java.time.DateTimeException serialization fails #319

olibraga opened this issue Sep 27, 2024 · 3 comments

Comments

@olibraga
Copy link

This code (using version 2.17.2, 2.16.2 and 2.13.5):

  ObjectMapper mapper = new JsonMapper().registerModule(new JavaTimeModule());
  JsonGenerator gen = mapper.createGenerator(System.out);
  gen.writeObject(new java.time.DateTimeException("dummy"));

will throw InvalidDefinitionException with message Java 8 date/time type 'java.time.DateTimeException' not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
which is obviously wrong as JavaTimeModule is added above.

This can be fixed in BeanUtil#checkUnsupportedType(JavaType)
by for example changing line:
if (className.indexOf('.', 10) >= 0) {
to:
if (className.indexOf('.', 10) >= 0 || className.equals("java.time.DateTimeException")) {

@cowtowncoder
Copy link
Member

Thank you for reporting this issue! I'll have to think of the best way to handle this.

@cowtowncoder
Copy link
Member

Created FasterXML/jackson-databind#4718 for jackson-databind change(s); this issue can remain to allow for adding tests on module side (if any needed)

@cowtowncoder cowtowncoder changed the title jackson-datatype-jsr310 fails java.time.DateTimeException serialization with wrong message java.time.DateTimeException serialization fails Sep 29, 2024
@cowtowncoder
Copy link
Member

cowtowncoder commented Sep 29, 2024

Fixed via FasterXML/jackson-databind#4718 for 2.18(.1).

.. . actually will backport in 2.17 (for 2.17.3) as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants