diff options
author | Tatu Saloranta <tatu.saloranta@iki.fi> | 2020-07-02 15:56:58 -0700 |
---|---|---|
committer | Tatu Saloranta <tatu.saloranta@iki.fi> | 2020-07-02 15:56:58 -0700 |
commit | d91cc6dbe6af0547ea6eb2429be2f94b200fc3b1 (patch) | |
tree | 5a4a334aa7871644759272f9219ff89e05c47c65 | |
parent | 41e3faa7216d196139c4873d9150f5981997e5b9 (diff) | |
parent | dc135ecbb660b09cd44f430d4dd1f5dd8f70e947 (diff) | |
download | jackson-databind-d91cc6dbe6af0547ea6eb2429be2f94b200fc3b1.tar.gz |
Merge branch '2.11' into 2.12
-rw-r--r-- | release-notes/VERSION-2.x | 5 | ||||
-rw-r--r-- | src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java | 39 | ||||
-rw-r--r-- | src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java | 34 |
3 files changed, 45 insertions, 33 deletions
diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 1b0463041..abe1ca684 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -40,6 +40,11 @@ Project: jackson-databind - Add `BeanDeserializerBase.isCaseInsensitive()` - Some refactoring of `CollectionDeserializer` to solve CSV array handling issues +2.11.2 (not yet released) + +#2783: Parser/Generator features not set when using `ObjectMapper.createParser()`, + `createGenerator()` + 2.11.1 (25-Jun-2020) #2486: Builder Deserialization with JsonCreator Value vs Array diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java index 353888852..da25f7666 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java +++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java @@ -1126,7 +1126,9 @@ public class ObjectMapper */ public JsonGenerator createGenerator(OutputStream out) throws IOException { _assertNotNull("out", out); - return _jsonFactory.createGenerator(out, JsonEncoding.UTF8); + JsonGenerator g = _jsonFactory.createGenerator(out, JsonEncoding.UTF8); + _serializationConfig.initialize(g); + return g; } /** @@ -1139,7 +1141,9 @@ public class ObjectMapper */ public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException { _assertNotNull("out", out); - return _jsonFactory.createGenerator(out, enc); + JsonGenerator g = _jsonFactory.createGenerator(out, enc); + _serializationConfig.initialize(g); + return g; } /** @@ -1152,7 +1156,9 @@ public class ObjectMapper */ public JsonGenerator createGenerator(Writer w) throws IOException { _assertNotNull("w", w); - return _jsonFactory.createGenerator(w); + JsonGenerator g = _jsonFactory.createGenerator(w); + _serializationConfig.initialize(g); + return g; } /** @@ -1165,7 +1171,9 @@ public class ObjectMapper */ public JsonGenerator createGenerator(File outputFile, JsonEncoding enc) throws IOException { _assertNotNull("outputFile", outputFile); - return _jsonFactory.createGenerator(outputFile, enc); + JsonGenerator g = _jsonFactory.createGenerator(outputFile, enc); + _serializationConfig.initialize(g); + return g; } /** @@ -1178,7 +1186,9 @@ public class ObjectMapper */ public JsonGenerator createGenerator(DataOutput out) throws IOException { _assertNotNull("out", out); - return _jsonFactory.createGenerator(out); + JsonGenerator g = _jsonFactory.createGenerator(out); + _serializationConfig.initialize(g); + return g; } /* @@ -3620,7 +3630,7 @@ public class ObjectMapper public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(resultFile, JsonEncoding.UTF8), value); + _writeValue(createGenerator(resultFile, JsonEncoding.UTF8), value); } /** @@ -3637,7 +3647,7 @@ public class ObjectMapper public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(out, JsonEncoding.UTF8), value); + _writeValue(createGenerator(out, JsonEncoding.UTF8), value); } /** @@ -3645,7 +3655,7 @@ public class ObjectMapper */ public void writeValue(DataOutput out, Object value) throws IOException { - _configAndWriteValue(createGenerator(out), value); + _writeValue(createGenerator(out), value); } /** @@ -3661,7 +3671,7 @@ public class ObjectMapper public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(w), value); + _writeValue(createGenerator(w), value); } /** @@ -3679,7 +3689,7 @@ public class ObjectMapper // alas, we have to pull the recycler directly here... SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler()); try { - _configAndWriteValue(createGenerator(sw), value); + _writeValue(createGenerator(sw), value); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: @@ -3703,7 +3713,7 @@ public class ObjectMapper { ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler()); try { - _configAndWriteValue(createGenerator(bb, JsonEncoding.UTF8), value); + _writeValue(createGenerator(bb, JsonEncoding.UTF8), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: @@ -4414,13 +4424,12 @@ public class ObjectMapper * Method called to configure the generator as necessary and then * call write functionality */ - protected final void _configAndWriteValue(JsonGenerator g, Object value) + protected final void _writeValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); - cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { - _configAndWriteCloseable(g, value, cfg); + _writeCloseable(g, value, cfg); return; } try { @@ -4436,7 +4445,7 @@ public class ObjectMapper * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ - private final void _configAndWriteCloseable(JsonGenerator g, Object value, SerializationConfig cfg) + private final void _writeCloseable(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException { Closeable toClose = (Closeable) value; diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java index d21250ec7..72c899c3c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java +++ b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java @@ -255,9 +255,8 @@ public class ObjectWriter JsonGenerator gen, boolean managedInput) throws IOException { - _configureGenerator(gen); return new SequenceWriter(_serializerProvider(), - gen, managedInput, _prefetch) + _configureGenerator(gen), managedInput, _prefetch) .init(wrapInArray); } @@ -675,7 +674,7 @@ public class ObjectWriter */ public JsonGenerator createGenerator(OutputStream out) throws IOException { _assertNotNull("out", out); - return _generatorFactory.createGenerator(out, JsonEncoding.UTF8); + return _configureGenerator(_generatorFactory.createGenerator(out, JsonEncoding.UTF8)); } /** @@ -688,7 +687,7 @@ public class ObjectWriter */ public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException { _assertNotNull("out", out); - return _generatorFactory.createGenerator(out, enc); + return _configureGenerator(_generatorFactory.createGenerator(out, enc)); } /** @@ -701,7 +700,7 @@ public class ObjectWriter */ public JsonGenerator createGenerator(Writer w) throws IOException { _assertNotNull("w", w); - return _generatorFactory.createGenerator(w); + return _configureGenerator(_generatorFactory.createGenerator(w)); } /** @@ -714,7 +713,7 @@ public class ObjectWriter */ public JsonGenerator createGenerator(File outputFile, JsonEncoding enc) throws IOException { _assertNotNull("outputFile", outputFile); - return _generatorFactory.createGenerator(outputFile, enc); + return _configureGenerator(_generatorFactory.createGenerator(outputFile, enc)); } /** @@ -727,7 +726,7 @@ public class ObjectWriter */ public JsonGenerator createGenerator(DataOutput out) throws IOException { _assertNotNull("out", out); - return _generatorFactory.createGenerator(out); + return _configureGenerator(_generatorFactory.createGenerator(out)); } /* @@ -770,8 +769,7 @@ public class ObjectWriter */ public SequenceWriter writeValues(JsonGenerator g) throws IOException { _assertNotNull("g", g); - _configureGenerator(g); - return _newSequenceWriter(false, g, false); + return _newSequenceWriter(false, _configureGenerator(g), false); } /** @@ -1022,7 +1020,7 @@ public class ObjectWriter public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(resultFile, JsonEncoding.UTF8), value); + _writeValue(createGenerator(resultFile, JsonEncoding.UTF8), value); } /** @@ -1039,7 +1037,7 @@ public class ObjectWriter public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(out, JsonEncoding.UTF8), value); + _writeValue(createGenerator(out, JsonEncoding.UTF8), value); } /** @@ -1055,7 +1053,7 @@ public class ObjectWriter public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { - _configAndWriteValue(createGenerator(w), value); + _writeValue(createGenerator(w), value); } /** @@ -1064,7 +1062,7 @@ public class ObjectWriter public void writeValue(DataOutput out, Object value) throws IOException { - _configAndWriteValue(createGenerator(out), value); + _writeValue(createGenerator(out), value); } /** @@ -1082,7 +1080,7 @@ public class ObjectWriter // alas, we have to pull the recycler directly here... SegmentedStringWriter sw = new SegmentedStringWriter(_generatorFactory._getBufferRecycler()); try { - _configAndWriteValue(createGenerator(sw), value); + _writeValue(createGenerator(sw), value); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: @@ -1106,7 +1104,7 @@ public class ObjectWriter { ByteArrayBuilder bb = new ByteArrayBuilder(_generatorFactory._getBufferRecycler()); try { - _configAndWriteValue(createGenerator(bb, JsonEncoding.UTF8), value); + _writeValue(createGenerator(bb, JsonEncoding.UTF8), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: @@ -1204,9 +1202,8 @@ public class ObjectWriter * Method called to configure the generator as necessary and then * call write functionality */ - protected final void _configAndWriteValue(JsonGenerator gen, Object value) throws IOException + protected final void _writeValue(JsonGenerator gen, Object value) throws IOException { - _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _writeCloseable(gen, value); return; @@ -1246,12 +1243,13 @@ public class ObjectWriter * * @since 2.5 */ - protected final void _configureGenerator(JsonGenerator gen) + protected final JsonGenerator _configureGenerator(JsonGenerator gen) { // order is slightly significant: both may change PrettyPrinter // settings. _config.initialize(gen); // since 2.5 _generatorSettings.initialize(gen); + return gen; } protected final void _assertNotNull(String paramName, Object src) { |