Skip to content

Commit 951c664

Browse files
committed
Removed JsonFactory property, which is redundant with the ObjectMapper property.
1 parent f1b9365 commit 951c664

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

org.springframework.web/src/main/java/org/springframework/http/converter/json/BindingJacksonHttpMessageConverter.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import java.util.List;
2222

2323
import org.codehaus.jackson.JsonEncoding;
24-
import org.codehaus.jackson.JsonFactory;
2524
import org.codehaus.jackson.JsonGenerator;
26-
import org.codehaus.jackson.map.MappingJsonFactory;
2725
import org.codehaus.jackson.map.ObjectMapper;
2826

2927
import org.springframework.http.HttpInputMessage;
@@ -38,7 +36,7 @@
3836
* Implementation of {@link org.springframework.http.converter.HttpMessageConverter HttpMessageConverter} that can read
3937
* and write JSON using <a href="http://jackson.codehaus.org/">Jackson's</a> {@link ObjectMapper}.
4038
*
41-
* <p>This converter can be used to bind to typed beans, or untyped {@link java.util.HashMap HashMap} instances.
39+
* <p>This converter can be used to bind to typed beans, or untyped {@link java.util.HashMap HashMap} instances.
4240
*
4341
* <p>By default, this converter supports {@code application/json}. This can be overridden by setting the {@link
4442
* #setSupportedMediaTypes(List) supportedMediaTypes} property, and overriding the {@link #getContentType(Object)}
@@ -51,13 +49,9 @@ public class BindingJacksonHttpMessageConverter<T> extends AbstractHttpMessageCo
5149

5250
private ObjectMapper objectMapper = new ObjectMapper();
5351

54-
private JsonFactory jsonFactory = new MappingJsonFactory();
55-
5652
private JsonEncoding encoding = JsonEncoding.UTF8;
5753

58-
/**
59-
* Construct a new {@code BindingJacksonHttpMessageConverter},
60-
*/
54+
/** Construct a new {@code BindingJacksonHttpMessageConverter}, */
6155
public BindingJacksonHttpMessageConverter() {
6256
super(new MediaType("application", "json"));
6357
}
@@ -71,16 +65,9 @@ public void setObjectMapper(ObjectMapper objectMapper) {
7165
this.objectMapper = objectMapper;
7266
}
7367

74-
/** Sets the {@code JsonFactory} for this converter. By default, a {@link MappingJsonFactory} is used. */
75-
public void setJsonFactory(JsonFactory jsonFactory) {
76-
Assert.notNull(jsonFactory, "'jsonFactory' must not be null");
77-
this.jsonFactory = jsonFactory;
78-
}
79-
80-
/**
81-
* Sets the {@code JsonEncoding} for this converter. By default, {@linkplain JsonEncoding#UTF8 UTF-8} is used.
82-
*/
68+
/** Sets the {@code JsonEncoding} for this converter. By default, {@linkplain JsonEncoding#UTF8 UTF-8} is used. */
8369
public void setEncoding(JsonEncoding encoding) {
70+
Assert.notNull(encoding, "'encoding' must not be null");
8471
this.encoding = encoding;
8572
}
8673

@@ -103,7 +90,8 @@ protected MediaType getContentType(T t) {
10390
@Override
10491
protected void writeInternal(T t, HttpOutputMessage outputMessage)
10592
throws IOException, HttpMessageNotWritableException {
106-
JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(outputMessage.getBody(), encoding);
93+
JsonGenerator jsonGenerator =
94+
objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);
10795
objectMapper.writeValue(jsonGenerator, t);
10896
}
10997
}

0 commit comments

Comments
 (0)