Skip to content

Commit deaf38f

Browse files
authored
Fix #3906 (#4057)
1 parent 035fba3 commit deaf38f

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

release-notes/CREDITS-2.x

+8-5
Original file line numberDiff line numberDiff line change
@@ -1102,20 +1102,23 @@ Tobias Preuss (johnjohndoe@github)
11021102
(2.10.3)
11031103

11041104
Eduard Tudenhöfner (nastra@github)
1105-
* Reported #2602, contributed fix for: ByteBufferSerializer produces unexpected results with
1106-
a duplicated ByteBuffer and a position > 0
1105+
* Reported #2602, contributed fix for: ByteBufferSerializer produces unexpected results with
1106+
a duplicated ByteBuffer and a position > 0
11071107
(2.10.3)
11081108

11091109
Alexander Shilov (ashlanderr@github)
1110-
* Reported, suggested fix for #2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
1110+
* Reported, suggested fix for #2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
11111111
(2.10.3)
11121112
11131113
Endre Stølsvik (stolsvik@github)
1114-
* Reported #2679: `ObjectMapper.readValue("123", Void.TYPE)` throws "should never occur"
1114+
* Reported #2679: `ObjectMapper.readValue("123", Void.TYPE)` throws "should never occur"
11151115
(2.10.4)
1116+
* Reported #3906: Regression: 2.15.0 breaks deserialization for records when
1117+
`mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE)`
1118+
(2.16.0)
11161119
11171120
Denis Kostousov (kostousov-ds@github)
1118-
* Reported #2787 (partial fix): NPE after add mixin for enum
1121+
* Reported #2787 (partial fix): NPE after add mixin for enum
11191122
(2.10.5)
11201123
11211124
Máté Rédecsi (rmatesz@github)

release-notes/VERSION-2.x

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Project: jackson-databind
1414
#3877: Add new `OptBoolean` valued property in `@JsonTypeInfo`, handling,
1515
to allow per-polymorphic type loose Type Id handling
1616
(contributed by Joo-Hyuk K)
17+
#3906: Regression: 2.15.0 breaks deserialization for records when
18+
`mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE)`
19+
(reported by Endre S)
1720
#3924: Incorrect target type when disabling coercion, trying to deserialize
1821
String from Array/Object
1922
(reported by João G)

src/main/java/com/fasterxml/jackson/databind/cfg/MapperConfigBase.java

+8
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,14 @@ public final VisibilityChecker<?> getDefaultVisibilityChecker(Class<?> baseType,
832832
vc = VisibilityChecker.Std.allPublicInstance();
833833
} else {
834834
vc = getDefaultVisibilityChecker();
835+
// 20-May-2023, tatu: [databind#3906] Must reset visibility for Records
836+
// to avoid hiding Constructors.
837+
if (ClassUtil.isRecordType(baseType)) {
838+
// But only if creator auto-detection enabled:
839+
if (isEnabled(MapperFeature.AUTO_DETECT_CREATORS)) {
840+
vc = vc.withCreatorVisibility(Visibility.NON_PRIVATE);
841+
}
842+
}
835843
}
836844
AnnotationIntrospector intr = getAnnotationIntrospector();
837845
if (intr != null) {

src/test-jdk14/java/com/fasterxml/jackson/databind/failing/RecordDeserialization3906Test.java renamed to src/test-jdk14/java/com/fasterxml/jackson/databind/records/RecordDeserialization3906Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.failing;
1+
package com.fasterxml.jackson.databind.records;
22

33
import com.fasterxml.jackson.annotation.JsonAutoDetect;
44
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;

0 commit comments

Comments
 (0)