Skip to content

Commit a035d3d

Browse files
committed
Merge branch '2.11'
2 parents 36436cd + 2f89b9c commit a035d3d

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

release-notes/CREDITS-2.x

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,10 @@ Stefan Wendt (stewe@github)
10131013
* Reported #2560: Check `WRAP_EXCEPTIONS` in `CollectionDeserializer.handleNonArray()`
10141014
(2.10.2)
10151015
1016+
Máté Rédecsi (rmatesz@github)
1017+
* Reported #953: i-I case convertion problem in Turkish locale with case-insensitive deserialization
1018+
(2.11.0)
1019+
10161020
Ville Koskela (vjkoskela@github)
10171021
* Contributed #2487: BeanDeserializerBuilder Protected Factory Method for Extension
10181022
(2.11.0)
@@ -1034,6 +1038,6 @@ Joseph Koshakow (jkosh44@github)
10341038
the same POJO for two different type ids
10351039
(2.11.0)
10361040

1037-
Máté Rédecsi (rmatesz@github)
1038-
* Reported #953: i-I case convertion problem in Turkish locale with case-insensitive deserialization
1041+
Haowei Wen (yushijinhun@github)
1042+
* Reported #2565: Java 8 `Optional` not working with `@JsonUnwrapped` on unwrappable type
10391043
(2.11.0)

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Project: jackson-databind
2525
for non-static inner classes
2626
#2525: Incorrect `JsonStreamContext` for `TokenBuffer` and `TreeTraversingParser`
2727
#2555: Use `@JsonProperty(index)` for sorting properties on serialization
28+
#2565: Java 8 `Optional` not working with `@JsonUnwrapped` on unwrappable type
29+
(reported by Haowei W)
2830
- Add `SerializerProvider.findContentValueSerializer()` methods
2931
3032
2.10.2 (not yet released)

src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ protected ReferenceTypeSerializer(ReferenceTypeSerializer<?> base, BeanProperty
9090
public JsonSerializer<T> unwrappingSerializer(NameTransformer transformer) {
9191
JsonSerializer<Object> valueSer = _valueSerializer;
9292
if (valueSer != null) {
93+
// 09-Dec-2019, tatu: [databind#2565] Can not assume that serializer in
94+
// question actually can unwrap
9395
valueSer = valueSer.unwrappingSerializer(transformer);
96+
if (valueSer == _valueSerializer) {
97+
return this;
98+
}
9499
}
95100
NameTransformer unwrapper = (_unwrapper == null) ? transformer
96101
: NameTransformer.chainedTransformer(transformer, _unwrapper);

src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKAtomicTypesDeserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static class Issue1256Bean {
9797
// [databind#2303]
9898
static class MyBean2303 {
9999
public AtomicReference<AtomicReference<Integer>> refRef;
100-
}
100+
}
101101

102102
/*
103103
/**********************************************************

src/test/java/com/fasterxml/jackson/databind/ser/jdk/AtomicTypeSerializationTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.concurrent.atomic.*;
66

77
import com.fasterxml.jackson.annotation.*;
8+
89
import com.fasterxml.jackson.databind.BaseMapTest;
910
import com.fasterxml.jackson.databind.ObjectMapper;
1011
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -64,13 +65,19 @@ static class Foo implements Strategy {
6465
}
6566
}
6667

68+
// [databind#2565]: problems with JsonUnwrapped, non-unwrappable type
69+
static class MyBean2565 {
70+
@JsonUnwrapped
71+
public AtomicReference<String> maybeText = new AtomicReference<>("value");
72+
}
73+
6774
/*
6875
/**********************************************************
6976
/* Test methods
7077
/**********************************************************
7178
*/
7279

73-
private final ObjectMapper MAPPER = objectMapper();
80+
private final ObjectMapper MAPPER = newJsonMapper();
7481

7582
public void testAtomicBoolean() throws Exception
7683
{
@@ -137,4 +144,11 @@ public void testPolymorphicReferenceListOf() throws Exception
137144
String json = MAPPER.writeValueAsString(new ContainerB());
138145
assertEquals("{\"strategy\":[" + EXPECTED + "]}", json);
139146
}
147+
148+
// [databind#2565]: problems with JsonUnwrapped, non-unwrappable type
149+
public void testWithUnwrappableUnwrapped() throws Exception
150+
{
151+
assertEquals(aposToQuotes("{'maybeText':'value'}"),
152+
MAPPER.writeValueAsString(new MyBean2565()));
153+
}
140154
}

0 commit comments

Comments
 (0)