File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
src/test-jdk17/java/com/fasterxml/jackson/databind/tofix Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .databind .tofix ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonValue ;
5+ import com .fasterxml .jackson .databind .testutil .DatabindTestUtil ;
6+ import com .fasterxml .jackson .databind .testutil .failure .JacksonTestFailureExpected ;
7+
8+ import org .junit .jupiter .api .Test ;
9+
10+ // [databind#4724] Deserialization behavior change with Java Records, JsonCreator and JsonValue between 2.17.2 => 2.18.0
11+ public class RecordJsonCreatorAndJsonValue4724Test
12+ extends DatabindTestUtil
13+ {
14+
15+ public record Something (String value ) {
16+ public Something {
17+ if (value == null || value .isEmpty ()) {
18+ throw new IllegalArgumentException ("Value cannot be null or empty" );
19+ }
20+ }
21+
22+ @ JsonCreator
23+ public static Something of (String value ) {
24+ if (value .isEmpty ()) {
25+ return null ;
26+ }
27+ return new Something (value );
28+ }
29+
30+ @ Override
31+ @ JsonValue
32+ public String toString () {
33+ return value ;
34+ }
35+ }
36+
37+ @ JacksonTestFailureExpected
38+ @ Test
39+ void deserialization () throws Exception {
40+ newJsonMapper ().readValue ("\" \" " , Something .class );
41+ }
42+
43+ }
You can’t perform that action at this time.
0 commit comments