Skip to content

Commit 0dfae66

Browse files
committed
Update release notes wrt #1172
1 parent 5d7b32e commit 0dfae66

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

release-notes/CREDITS-2.x

+4
Original file line numberDiff line numberDiff line change
@@ -1642,3 +1642,7 @@ Antti Lampinen (arlampin@github)
16421642
* Reported #3897: 2.15.0 breaks deserialization when POJO/Record only has a single field
16431643
and is marked `Access.WRITE_ONLY`
16441644
(2.15.1)
1645+
1646+
Dmitry Bolotin (dbolotin@github)
1647+
* Reported #1172: `@JsonView` doesn't work with `@JsonCreator`
1648+
(2.15.4)

release-notes/VERSION-2.x

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Project: jackson-databind
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
Not yet released
8+
9+
#1172: `@JsonView` doesn't work with `@JsonCreator`
10+
(reported by Dmitry B)
11+
712
2.15.3 (12-Oct-2023)
813
914
#3968: Records with additional constructors failed to deserialize

src/test/java/com/fasterxml/jackson/databind/views/ViewsWithCreatorTest.java

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package com.fasterxml.jackson.databind.views;
22

3-
import static com.fasterxml.jackson.databind.BaseMapTest.newJsonMapper;
4-
import static org.junit.Assert.assertEquals;
53
import com.fasterxml.jackson.annotation.*;
4+
5+
import com.fasterxml.jackson.databind.BaseMapTest;
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.ObjectReader;
8-
import org.junit.Test;
98

109
public class ViewsWithCreatorTest
10+
extends BaseMapTest
1111
{
12-
13-
public static class View { }
14-
public static class View1 extends View { }
15-
public static class View2 extends View { }
12+
static class View { }
13+
static class View1 extends View { }
14+
static class View2 extends View { }
1615

1716
@JsonAutoDetect(
1817
fieldVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
@@ -72,25 +71,27 @@ public String toString() {
7271
}
7372
}
7473

75-
@Test
76-
public void testWithJsonCreator() throws Exception {
77-
ObjectMapper mapper = newJsonMapper();
78-
ObjectReader reader = mapper.readerFor(ObjWithCreator.class).withView(View1.class);
74+
private final ObjectMapper MAPPER = newJsonMapper();
75+
76+
// [databind#1172]
77+
public void testWithJsonCreator() throws Exception
78+
{
79+
ObjectReader reader = MAPPER.readerFor(ObjWithCreator.class).withView(View1.class);
7980

8081
// serialize first,
81-
String JSON = mapper.writeValueAsString(new ObjWithCreator("a", "b", "c"));
82+
String json = MAPPER.writeValueAsString(new ObjWithCreator("a", "b", "c"));
8283
// then back
83-
assertEquals("a-b-null", reader.readValue(JSON).toString());
84+
assertEquals("a-b-null", reader.readValue(json).toString());
8485
}
8586

86-
@Test
87-
public void testWithoutJsonCreator() throws Exception {
88-
ObjectMapper mapper = newJsonMapper();
89-
ObjectReader reader = mapper.readerFor(ObjWithoutCreator.class).withView(View1.class);
87+
// [databind#1172]
88+
public void testWithoutJsonCreator() throws Exception
89+
{
90+
ObjectReader reader = MAPPER.readerFor(ObjWithoutCreator.class).withView(View1.class);
9091

9192
// serialize first,
92-
String JSON = mapper.writeValueAsString(new ObjWithoutCreator("a", "b", "c"));
93+
String json = MAPPER.writeValueAsString(new ObjWithoutCreator("a", "b", "c"));
9394
// then back
94-
assertEquals("a-b-null", reader.readValue(JSON).toString());
95+
assertEquals("a-b-null", reader.readValue(json).toString());
9596
}
9697
}

0 commit comments

Comments
 (0)