Skip to content

Commit d7c20a5

Browse files
committed
Merge branch '2.11'
2 parents e60e1cc + 172b4e3 commit d7c20a5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/main/java/com/fasterxml/jackson/databind/SequenceWriter.java

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public SequenceWriter(DefaultSerializerProvider prov, JsonGenerator gen,
9191
_dynamicSerializers = PropertySerializerMap.emptyForRootValues();
9292
}
9393

94+
/**
95+
* Internal method called by {@link ObjectWriter}: should not be called by code
96+
* outside {@code jackson-databind} classes.
97+
*/
9498
public SequenceWriter init(boolean wrapInArray) throws IOException
9599
{
96100
if (wrapInArray) {

src/test/java/com/fasterxml/jackson/databind/format/EnumFormatShapeTest.java

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.fasterxml.jackson.databind.format;
22

3+
import java.util.Collections;
4+
import java.util.Map;
5+
36
import com.fasterxml.jackson.annotation.*;
47
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
58

@@ -70,6 +73,24 @@ static class ColorWrapper {
7073
}
7174
}
7275

76+
// [databind#2576]
77+
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
78+
public enum Enum2576 {
79+
DEFAULT("default"),
80+
ATTRIBUTES("attributes") {
81+
@Override
82+
public String toString() {
83+
return name();
84+
}
85+
};
86+
87+
private final String key;
88+
private Enum2576(String key) {
89+
this.key = key;
90+
}
91+
public String getKey() { return this.key; }
92+
}
93+
7394
/*
7495
/**********************************************************
7596
/* Tests
@@ -113,4 +134,12 @@ public void testEnumPropertyAsNumber() throws Exception {
113134
assertEquals(String.format(aposToQuotes("{'color':%s}"), Color.GREEN.ordinal()),
114135
MAPPER.writeValueAsString(new ColorWrapper(Color.GREEN)));
115136
}
137+
138+
// [databind#2576]
139+
public void testEnumWithMethodOverride() throws Exception {
140+
String stringResult = MAPPER.writeValueAsString(Enum2576.ATTRIBUTES);
141+
Map<?,?> result = MAPPER.readValue(stringResult, Map.class);
142+
Map<String,String> exp = Collections.singletonMap("key", "attributes");
143+
assertEquals(exp, result);
144+
}
116145
}

0 commit comments

Comments
 (0)