Skip to content

Commit e6df267

Browse files
committed
Update release notes wrt #2719 (and minor optimization wrt fix)
1 parent 20053ea commit e6df267

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,3 +1114,8 @@ Mike Gilbode (gilbode@github)
11141114
Nate Bauernfeind (nbauernfeind@github)
11151115
* Reported #2091: `ReferenceType` does not expose valid containedType
11161116
(2.12.0)
1117+
1118+
David Bidorff (bidorffOL@github)
1119+
* Reported, contributed fix for #2719: `FAIL_ON_IGNORED_PROPERTIES` does not throw
1120+
on `READONLY` properties with an explicit name
1121+
(2.12.0)

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Project: jackson-databind
1919
#2683: Explicitly fail (de)serialization of `java.time.*` types in absence of
2020
registered custom (de)serializers
2121
#2707: Improve description included in by `DeserializationContext.handleUnexpectedToken()`
22+
#2719: `FAIL_ON_IGNORED_PROPERTIES` does not throw on `READONLY` properties with
23+
an explicit name
24+
(reported, fix contributed by David B)
2225
- Add `BeanDeserializerBase.isCaseInsensitive()`
2326
- Some refactoring of `CollectionDeserializer` to solve CSV array handling issues
2427

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -792,18 +792,10 @@ protected void _removeUnwantedAccessor(Map<String, POJOPropertyBuilder> props)
792792

793793
while (it.hasNext()) {
794794
POJOPropertyBuilder prop = it.next();
795-
// [databind#2719]: ignore the explicit names when they are available
796-
Collection<PropertyName> names = prop.findExplicitNames();
797-
if (names.isEmpty()) {
798-
names = Collections.singleton(prop.getFullName());
799-
}
800795
// 26-Jan-2017, tatu: [databind#935]: need to denote removal of
801-
JsonProperty.Access acc = prop.removeNonVisible(inferMutators);
802-
if (acc == JsonProperty.Access.READ_ONLY) {
803-
for (PropertyName explicitName : names) {
804-
_collectIgnorals(explicitName.getSimpleName());
805-
}
806-
}
796+
// 16-May-2020, tatu: [databind#2719]: need to pass `this` to allow
797+
// addition of ignorals wrt explicit name
798+
prop.removeNonVisible(inferMutators, _forSerialization ? null : this);
807799
}
808800
}
809801

@@ -812,9 +804,9 @@ protected void _removeUnwantedAccessor(Map<String, POJOPropertyBuilder> props)
812804
* of known ignored properties; this helps in proper reporting of
813805
* errors.
814806
*/
815-
private void _collectIgnorals(String name)
807+
protected void _collectIgnorals(String name)
816808
{
817-
if (!_forSerialization) {
809+
if (!_forSerialization && (name != null)) {
818810
if (_ignoredPropertyNames == null) {
819811
_ignoredPropertyNames = new HashSet<String>();
820812
}

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,19 @@ public void removeIgnored()
783783
_ctorParameters = _removeIgnored(_ctorParameters);
784784
}
785785

786+
@Deprecated // since 2.12
787+
public JsonProperty.Access removeNonVisible(boolean inferMutators) {
788+
return removeNonVisible(inferMutators, null);
789+
}
790+
786791
/**
787792
* @param inferMutators Whether mutators can be "pulled in" by visible
788793
* accessors or not.
794+
*
795+
* @since 2.12 (earlier had different signature)
789796
*/
790-
public JsonProperty.Access removeNonVisible(boolean inferMutators)
797+
public JsonProperty.Access removeNonVisible(boolean inferMutators,
798+
POJOPropertiesCollector parent)
791799
{
792800
/* 07-Jun-2015, tatu: With 2.6, we will allow optional definition
793801
* of explicit access type for property; if not "AUTO", it will
@@ -799,6 +807,15 @@ public JsonProperty.Access removeNonVisible(boolean inferMutators)
799807
}
800808
switch (acc) {
801809
case READ_ONLY:
810+
// [databind#2719]: Need to add ignorals, first, keeping in mind
811+
// we have not yet resolved explicit names, so include implicit
812+
// and possible explicit names
813+
if (parent != null) {
814+
parent._collectIgnorals(getName());
815+
for (PropertyName pn : findExplicitNames()) {
816+
parent._collectIgnorals(pn.getSimpleName());
817+
}
818+
}
802819
// Remove setters, creators for sure, but fields too if deserializing
803820
_setters = null;
804821
_ctorParameters = null;

0 commit comments

Comments
 (0)