From c77e7e7912f4a132ba2dc023bf78df8d2b26f0ed Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 16 Feb 2024 16:55:24 -0800 Subject: [PATCH] Fix #112: make custom serialization work for `java.nio.file.Path` --- .../jackson/jr/ob/impl/ValueLocatorBase.java | 16 ++++++++-------- .../impl}/ValueWriterModifier112Test.java | 2 +- release-notes/CREDITS-2.x | 6 ++++++ release-notes/VERSION-2.x | 3 +++ 4 files changed, 18 insertions(+), 9 deletions(-) rename jr-objects/src/test/java/com/fasterxml/jackson/jr/{failing => ob/impl}/ValueWriterModifier112Test.java (98%) diff --git a/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java b/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java index 05421f33..15f8bb99 100644 --- a/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java +++ b/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueLocatorBase.java @@ -236,21 +236,21 @@ protected int _findSimpleType(Class raw, boolean forSer) if (UUID.class.isAssignableFrom(raw)) { return SER_UUID; } - /* May or may not help with deser, but recognized nonetheless; - * on assumption that Beans should rarely implement `CharSequence` - */ + // May or may not help with deser, but recognized nonetheless; + // on assumption that Beans should rarely implement `CharSequence` if (CharSequence.class.isAssignableFrom(raw)) { return SER_CHARACTER_SEQUENCE; } - /* `Iterable` can be added on all kinds of things, and it won't - * help at all with deserialization; hence only use for serialization. - */ + // `Iterable` can be added on all kinds of things, and it won't + // help at all with deserialization; hence only use for serialization. if (forSer && Iterable.class.isAssignableFrom(raw)) { - return SER_ITERABLE; + // 16-Feb-2024, tatu: [jackson-jr#112] java.nio.file.Path is not really Iterable + if (!java.nio.file.Path.class.isAssignableFrom(raw)) { + return SER_ITERABLE; + } } // Ok. I give up, no idea! return SER_UNKNOWN; } - } diff --git a/jr-objects/src/test/java/com/fasterxml/jackson/jr/failing/ValueWriterModifier112Test.java b/jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/ValueWriterModifier112Test.java similarity index 98% rename from jr-objects/src/test/java/com/fasterxml/jackson/jr/failing/ValueWriterModifier112Test.java rename to jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/ValueWriterModifier112Test.java index 29b2df0f..97db82c6 100644 --- a/jr-objects/src/test/java/com/fasterxml/jackson/jr/failing/ValueWriterModifier112Test.java +++ b/jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/ValueWriterModifier112Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.jr.failing; +package com.fasterxml.jackson.jr.ob.impl; import java.io.File; import java.io.IOException; diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 266be02a..67db91bb 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -33,3 +33,9 @@ Reed Passaretti (@reed53) * Reported #107: Cannot deserialize `byte[]` from JSON `null` value (2.15.3) + +Julian Honnen (@jhonnen) + +* Reported #112: `overrideStandardValueWriter` only applied to first `java.nio.file.Path` + valued field of bean + (2.17.0) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 5d73db04..bc61476d 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -15,6 +15,9 @@ Modules: #78: Deserializes "null" to "0.0" for `java.lang.Double` (wrapper) (reported by @bill-phast) +#112: `overrideStandardValueWriter` only applied to first `java.nio.file.Path` + valued field of bean + (reported by Julian H) 2.16.1 (24-Dec-2023)