This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git
The following commit(s) were added to refs/heads/master by this push:
new b1c44d5 [JOHNZON-321] avoid conflict for primitive converters due to
the new jsonb enum converter
b1c44d5 is described below
commit b1c44d56f764d32f2500f3438689b19ddfedde3a
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Wed Aug 19 09:46:55 2020 +0200
[JOHNZON-321] avoid conflict for primitive converters due to the new jsonb
enum converter
---
.../src/main/java/org/apache/johnzon/mapper/Mappings.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git
a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Mappings.java
b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Mappings.java
index 751440d..37259d7 100644
--- a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Mappings.java
+++ b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Mappings.java
@@ -685,7 +685,7 @@ public class Mappings {
if (adapterEntry.getKey().getFrom() == type && !(
// ignore internal converters to let primitives be
correctly handled
ConverterAdapter.class.isInstance(adapterEntry.getValue()) &&
-
ConverterAdapter.class.cast(adapterEntry.getValue()).getConverter().getClass().getName().startsWith("org.apache.johnzon.mapper.")))
{
+
isBuiltInJohnzonConverter(ConverterAdapter.class.cast(adapterEntry.getValue()).getConverter())))
{
if (converter != null) {
throw new IllegalArgumentException("Ambiguous
adapter for " + decoratedType);
@@ -706,6 +706,14 @@ public class Mappings {
return converter;
}
+ private boolean isBuiltInJohnzonConverter(final Converter<?> converter) {
+ final Class<?> clazz = converter.getClass();
+ // don't reduce too much this package filter, we really want to filter
the mapper module ones
+ return clazz.getName().startsWith("org.apache.johnzon.mapper.") ||
+ // jsonb adds a custom converter for enums so we must filter
this one too
+
(MapperConfig.CustomEnumConverter.class.isAssignableFrom(clazz) &&
clazz.getName().startsWith("org.apache.johnzon."));
+ }
+
private static class MapBuilderReader implements AccessMode.Reader {
private final Map<String, Getter> getters;
private final Map<String, Object> template;