Skip to content

Commit 89c11a8

Browse files
committed
Merge branch '2.16'
2 parents 94d450c + b2ab29c commit 89c11a8

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/main/java/tools/jackson/databind/ser/BasicSerializerFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ public ValueSerializer<Object> createKeySerializer(SerializerProvider ctxt, Java
218218
}
219219
// need to pass both type of key Object (on which accessor called), and actual
220220
// value type that `JsonType`-annotated accessor returns (or contains, in case of field)
221-
ser = new JsonValueSerializer(keyType, acc.getType(), false, null, delegate, acc);
221+
ser = JsonValueSerializer.construct(config, keyType, acc.getType(),
222+
false, null, delegate, acc);
222223
} else {
223224
ser = JDKKeySerializers.getFallbackKeySerializer(config, keyType.getRawClass(),
224225
beanDesc.getClassInfo());
@@ -328,8 +329,8 @@ protected final ValueSerializer<?> findSerializerByAnnotations(SerializerProvide
328329
ValueSerializer<Object> ser = findSerializerFromAnnotation(ctxt, valueAccessor);
329330
JavaType valueType = valueAccessor.getType();
330331
TypeSerializer vts = ctxt.findTypeSerializer(valueType);
331-
return new JsonValueSerializer(type, valueType, /* static typing */ false,
332-
vts, ser, valueAccessor);
332+
return JsonValueSerializer.construct(ctxt.getConfig(), type, valueType,
333+
/* static typing */ false, vts, ser, valueAccessor);
333334
}
334335
// No well-known annotations...
335336
return null;

src/main/java/tools/jackson/databind/ser/jackson/JsonValueSerializer.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class JsonValueSerializer
5656
*/
5757
protected final boolean _forceTypeInformation;
5858

59+
protected final Set<String> _ignoredProperties;
60+
5961
/*
6062
/**********************************************************************
6163
/* Life-cycle
@@ -68,16 +70,18 @@ public class JsonValueSerializer
6870
* {@link tools.jackson.databind.annotation.JsonSerialize#using}), otherwise
6971
* null
7072
*/
71-
public JsonValueSerializer(JavaType nominalType,
73+
protected JsonValueSerializer(JavaType nominalType,
7274
JavaType valueType, boolean staticTyping,
7375
TypeSerializer vts, ValueSerializer<?> ser,
74-
AnnotatedMember accessor)
76+
AnnotatedMember accessor,
77+
Set<String> ignoredProperties)
7578
{
7679
super(nominalType, null, vts, ser);
7780
_valueType = valueType;
7881
_staticTyping = staticTyping;
7982
_accessor = accessor;
8083
_forceTypeInformation = true; // gets reconsidered when we are contextualized
84+
_ignoredProperties = ignoredProperties;
8185
}
8286

8387
protected JsonValueSerializer(JsonValueSerializer src, BeanProperty property,
@@ -88,6 +92,20 @@ protected JsonValueSerializer(JsonValueSerializer src, BeanProperty property,
8892
_accessor = src._accessor;
8993
_staticTyping = src._staticTyping;
9094
_forceTypeInformation = forceTypeInfo;
95+
_ignoredProperties = src._ignoredProperties;
96+
}
97+
98+
public static JsonValueSerializer construct(SerializationConfig config,
99+
JavaType nominalType,
100+
JavaType valueType, boolean staticTyping,
101+
TypeSerializer vts, ValueSerializer<?> ser,
102+
AnnotatedMember accessor)
103+
{
104+
JsonIgnoreProperties.Value ignorals = config.getAnnotationIntrospector()
105+
.findPropertyIgnoralByName(config, accessor);
106+
return new JsonValueSerializer(nominalType, valueType, staticTyping,
107+
vts, ser, accessor,
108+
ignorals.findIgnoredForSerialization());
91109
}
92110

93111
public JsonValueSerializer withResolved(BeanProperty property,

src/test/java/tools/jackson/databind/ser/filter/JsonValueIgnore3647Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// [databind#3647] : Support @JsonIgnoreProperties to work with @JsonValue
1010
public class JsonValueIgnore3647Test extends BaseMapTest
1111
{
12-
static class Foo3647 {
12+
final static class Foo3647 {
1313
public String p1 = "hello";
1414
public String p2 = "world";
1515
}

0 commit comments

Comments
 (0)