aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatu Saloranta <tatu.saloranta@iki.fi>2020-07-02 16:10:23 -0700
committerTatu Saloranta <tatu.saloranta@iki.fi>2020-07-02 16:10:23 -0700
commitdc989c92413b49947f043e796d22074bcd52100c (patch)
tree2c932fedf2a013915207cffba98af9878757c348 /src
parentdc135ecbb660b09cd44f430d4dd1f5dd8f70e947 (diff)
downloadjackson-databind-dc989c92413b49947f043e796d22074bcd52100c.tar.gz
Minor changes to prevent compatibility issues with IonMapper
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java25
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java19
2 files changed, 30 insertions, 14 deletions
diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
index 385f79ba6..ef1afb5d1 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
@@ -3599,7 +3599,7 @@ public class ObjectMapper
public void writeValue(File resultFile, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(resultFile, JsonEncoding.UTF8), value);
+ _writeValueAndClose(createGenerator(resultFile, JsonEncoding.UTF8), value);
}
/**
@@ -3616,7 +3616,7 @@ public class ObjectMapper
public void writeValue(OutputStream out, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(out, JsonEncoding.UTF8), value);
+ _writeValueAndClose(createGenerator(out, JsonEncoding.UTF8), value);
}
/**
@@ -3624,7 +3624,7 @@ public class ObjectMapper
*/
public void writeValue(DataOutput out, Object value) throws IOException
{
- _writeValue(createGenerator(out), value);
+ _writeValueAndClose(createGenerator(out), value);
}
/**
@@ -3640,7 +3640,7 @@ public class ObjectMapper
public void writeValue(Writer w, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(w), value);
+ _writeValueAndClose(createGenerator(w), value);
}
/**
@@ -3658,7 +3658,7 @@ public class ObjectMapper
// alas, we have to pull the recycler directly here...
SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler());
try {
- _writeValue(createGenerator(sw), value);
+ _writeValueAndClose(createGenerator(sw), value);
} catch (JsonProcessingException e) {
throw e;
} catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
@@ -3682,7 +3682,7 @@ public class ObjectMapper
{
ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
try {
- _writeValue(createGenerator(bb, JsonEncoding.UTF8), value);
+ _writeValueAndClose(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:
@@ -4392,8 +4392,10 @@ public class ObjectMapper
/**
* Method called to configure the generator as necessary and then
* call write functionality
+ *
+ * @since 2.11.2
*/
- protected final void _writeValue(JsonGenerator g, Object value)
+ protected final void _writeValueAndClose(JsonGenerator g, Object value)
throws IOException
{
SerializationConfig cfg = getSerializationConfig();
@@ -4450,6 +4452,15 @@ public class ObjectMapper
toClose.close();
}
+ /**
+ * @deprecated Since 2.11.2 Use {@link #_writeValueAndClose} instead
+ */
+ @Deprecated // since 2.11.2 (to remove earliest from 2.13)
+ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException {
+ getSerializationConfig().initialize(g);
+ _writeValueAndClose(g, value);
+ }
+
/*
/**********************************************************
/* Internal methods for deserialization, overridable
diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
index 72c899c3c..df42a8e83 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java
@@ -980,6 +980,9 @@ public class ObjectWriter
/**
* Method that can be used to serialize any Java value as
* JSON output, using provided {@link JsonGenerator}.
+ *<p>
+ * Note that the given {@link JsonGenerator} is not closed; caller
+ * is expected to handle that as necessary.
*/
public void writeValue(JsonGenerator g, Object value) throws IOException
{
@@ -1020,7 +1023,7 @@ public class ObjectWriter
public void writeValue(File resultFile, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(resultFile, JsonEncoding.UTF8), value);
+ _writeValueAndClose(createGenerator(resultFile, JsonEncoding.UTF8), value);
}
/**
@@ -1037,7 +1040,7 @@ public class ObjectWriter
public void writeValue(OutputStream out, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(out, JsonEncoding.UTF8), value);
+ _writeValueAndClose(createGenerator(out, JsonEncoding.UTF8), value);
}
/**
@@ -1053,7 +1056,7 @@ public class ObjectWriter
public void writeValue(Writer w, Object value)
throws IOException, JsonGenerationException, JsonMappingException
{
- _writeValue(createGenerator(w), value);
+ _writeValueAndClose(createGenerator(w), value);
}
/**
@@ -1062,7 +1065,7 @@ public class ObjectWriter
public void writeValue(DataOutput out, Object value)
throws IOException
{
- _writeValue(createGenerator(out), value);
+ _writeValueAndClose(createGenerator(out), value);
}
/**
@@ -1080,7 +1083,7 @@ public class ObjectWriter
// alas, we have to pull the recycler directly here...
SegmentedStringWriter sw = new SegmentedStringWriter(_generatorFactory._getBufferRecycler());
try {
- _writeValue(createGenerator(sw), value);
+ _writeValueAndClose(createGenerator(sw), value);
} catch (JsonProcessingException e) {
throw e;
} catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
@@ -1104,7 +1107,7 @@ public class ObjectWriter
{
ByteArrayBuilder bb = new ByteArrayBuilder(_generatorFactory._getBufferRecycler());
try {
- _writeValue(createGenerator(bb, JsonEncoding.UTF8), value);
+ _writeValueAndClose(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:
@@ -1201,8 +1204,10 @@ public class ObjectWriter
/**
* Method called to configure the generator as necessary and then
* call write functionality
+ *
+ * @since 2.11.2
*/
- protected final void _writeValue(JsonGenerator gen, Object value) throws IOException
+ protected final void _writeValueAndClose(JsonGenerator gen, Object value) throws IOException
{
if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) {
_writeCloseable(gen, value);