Skip to content

Commit 35362a0

Browse files
committed
Unfix #357; should help with other problems like JAXB module issue 54 (FasterXML/jackson-module-jaxb-annotations#54)
1 parent eae6759 commit 35362a0

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ public ContextAttributes withPerCallAttribute(Object key, Object value)
177177
// need to mask nulls to ensure default values won't be showing
178178
if (_shared.containsKey(key)) {
179179
value = NULL_SURROGATE;
180-
} else {
180+
} else if ((_nonShared == null) || !_nonShared.containsKey(key)) {
181181
// except if non-mutable shared list has no entry, we don't care
182182
return this;
183+
} else {
184+
_nonShared.remove(key);
185+
return this;
183186
}
184187
}
185-
186188
// a special case: create non-shared instance if need be
187189
if (_nonShared == null) {
188190
return nonSharedInstance(key, value);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,11 @@ protected JsonSerializer<?> findConvertingContentSerializer(SerializerProvider p
394394
*/
395395
Object ob = provider.getAttribute(CONVERTING_CONTENT_CONVERTER_LOCK);
396396
if (ob != null) {
397-
return existingSerializer;
397+
if (ob == Boolean.TRUE) { // just to ensure it's value we added.
398+
return existingSerializer;
399+
}
398400
}
399-
401+
400402
final AnnotationIntrospector intr = provider.getAnnotationIntrospector();
401403
if (intr != null && prop != null) {
402404
AnnotatedMember m = prop.getMember();

src/test/java/com/fasterxml/jackson/databind/convert/TestConvertingSerializer.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,4 @@ public void testIssue731() throws Exception
218218
// must be {"a":2,"b":4}
219219
assertEquals("{\"a\":2,\"b\":4}", json);
220220
}
221-
222-
// [databind#357]
223-
public void testConverterForList357() throws Exception {
224-
String json = objectWriter().writeValueAsString(new ListWrapper());
225-
assertEquals("{\"list\":[[\"Hello world!\"]]}", json);
226-
}
227221
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
6+
7+
import com.fasterxml.jackson.databind.util.StdConverter;
8+
9+
public class TestConvertingSerializer357
10+
extends com.fasterxml.jackson.databind.BaseMapTest
11+
{
12+
// [databind#357]
13+
static class Value { }
14+
15+
static class ListWrapper {
16+
@JsonSerialize(contentConverter = ValueToStringListConverter.class)
17+
public List<Value> list = Arrays.asList(new Value());
18+
}
19+
20+
static class ValueToStringListConverter extends StdConverter<Value, List<String>> {
21+
@Override
22+
public List<String> convert(Value value) {
23+
return Arrays.asList("Hello world!");
24+
}
25+
}
26+
27+
/*
28+
/**********************************************************
29+
/* Test methods
30+
/**********************************************************
31+
*/
32+
33+
// [databind#357]
34+
public void testConverterForList357() throws Exception {
35+
String json = objectWriter().writeValueAsString(new ListWrapper());
36+
assertEquals("{\"list\":[[\"Hello world!\"]]}", json);
37+
}
38+
}

0 commit comments

Comments
 (0)