Skip to content

Commit 0793e87

Browse files
committed
And then replacing/removing JsonGenerationException with StreamWriteException where possible
1 parent 8122144 commit 0793e87

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.fasterxml.jackson.annotation.*;
1414
import com.fasterxml.jackson.core.*;
1515
import com.fasterxml.jackson.core.exc.StreamReadException;
16+
import com.fasterxml.jackson.core.exc.StreamWriteException;
1617
import com.fasterxml.jackson.core.io.CharacterEscapes;
1718
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
1819
import com.fasterxml.jackson.core.type.ResolvedType;
@@ -3106,7 +3107,7 @@ public JsonNode readTree(URL source) throws IOException
31063107
*/
31073108
@Override
31083109
public void writeValue(JsonGenerator g, Object value)
3109-
throws IOException, JsonGenerationException, JsonMappingException
3110+
throws IOException, StreamWriteException, JsonMappingException
31103111
{
31113112
_assertNotNull("g", g);
31123113
SerializationConfig config = getSerializationConfig();
@@ -3679,7 +3680,7 @@ public <T> T readValue(DataInput src, JavaType valueType) throws IOException
36793680
* JSON output, written to File provided.
36803681
*/
36813682
public void writeValue(File resultFile, Object value)
3682-
throws IOException, JsonGenerationException, JsonMappingException
3683+
throws IOException, StreamWriteException, JsonMappingException
36833684
{
36843685
_writeValueAndClose(createGenerator(resultFile, JsonEncoding.UTF8), value);
36853686
}
@@ -3696,7 +3697,7 @@ public void writeValue(File resultFile, Object value)
36963697
* is closed).
36973698
*/
36983699
public void writeValue(OutputStream out, Object value)
3699-
throws IOException, JsonGenerationException, JsonMappingException
3700+
throws IOException, StreamWriteException, JsonMappingException
37003701
{
37013702
_writeValueAndClose(createGenerator(out, JsonEncoding.UTF8), value);
37023703
}
@@ -3720,7 +3721,7 @@ public void writeValue(DataOutput out, Object value) throws IOException
37203721
* is closed).
37213722
*/
37223723
public void writeValue(Writer w, Object value)
3723-
throws IOException, JsonGenerationException, JsonMappingException
3724+
throws IOException, StreamWriteException, JsonMappingException
37243725
{
37253726
_writeValueAndClose(createGenerator(w), value);
37263727
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.concurrent.atomic.AtomicReference;
99

1010
import com.fasterxml.jackson.core.*;
11+
import com.fasterxml.jackson.core.exc.StreamWriteException;
1112
import com.fasterxml.jackson.core.io.CharacterEscapes;
1213
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
1314
import com.fasterxml.jackson.core.io.SerializedString;
@@ -1021,7 +1022,7 @@ public void writeValue(JsonGenerator g, Object value) throws IOException
10211022
* JSON output, written to File provided.
10221023
*/
10231024
public void writeValue(File resultFile, Object value)
1024-
throws IOException, JsonGenerationException, JsonMappingException
1025+
throws IOException, StreamWriteException, JsonMappingException
10251026
{
10261027
_writeValueAndClose(createGenerator(resultFile, JsonEncoding.UTF8), value);
10271028
}
@@ -1038,7 +1039,7 @@ public void writeValue(File resultFile, Object value)
10381039
* is closed).
10391040
*/
10401041
public void writeValue(OutputStream out, Object value)
1041-
throws IOException, JsonGenerationException, JsonMappingException
1042+
throws IOException, StreamWriteException, JsonMappingException
10421043
{
10431044
_writeValueAndClose(createGenerator(out, JsonEncoding.UTF8), value);
10441045
}
@@ -1054,7 +1055,7 @@ public void writeValue(OutputStream out, Object value)
10541055
* is closed).
10551056
*/
10561057
public void writeValue(Writer w, Object value)
1057-
throws IOException, JsonGenerationException, JsonMappingException
1058+
throws IOException, StreamWriteException, JsonMappingException
10581059
{
10591060
_writeValueAndClose(createGenerator(w), value);
10601061
}
@@ -1063,7 +1064,7 @@ public void writeValue(Writer w, Object value)
10631064
* @since 2.8
10641065
*/
10651066
public void writeValue(DataOutput out, Object value)
1066-
throws IOException
1067+
throws IOException, StreamWriteException, JsonMappingException
10671068
{
10681069
_writeValueAndClose(createGenerator(out), value);
10691070
}

src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public DOMSerializer() {
3333

3434
@Override
3535
public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider)
36-
throws IOException, JsonGenerationException
36+
throws IOException
3737
{
3838
if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS");
3939
LSSerializer writer = _domImpl.createLSSerializer();

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,11 +797,10 @@ protected void serializeFields(Object bean, JsonGenerator gen, SerializerProvide
797797
*/
798798
protected void serializeFieldsFiltered(Object bean, JsonGenerator gen,
799799
SerializerProvider provider)
800-
throws IOException, JsonGenerationException
800+
throws IOException
801801
{
802-
/* note: almost verbatim copy of "serializeFields"; copied (instead of merged)
803-
* so that old method need not add check for existence of filter.
804-
*/
802+
// note: almost verbatim copy of "serializeFields"; copied (instead of merged)
803+
// so that old method need not add check for existence of filter.
805804
final BeanPropertyWriter[] props;
806805
if (_filteredProps != null && provider.getActiveView() != null) {
807806
props = _filteredProps;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static class AtomicBooleanSerializer
6363
public AtomicBooleanSerializer() { super(AtomicBoolean.class, false); }
6464

6565
@Override
66-
public void serialize(AtomicBoolean value, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonGenerationException {
66+
public void serialize(AtomicBoolean value, JsonGenerator gen, SerializerProvider provider) throws IOException {
6767
gen.writeBoolean(value.get());
6868
}
6969

@@ -84,7 +84,7 @@ public static class AtomicIntegerSerializer
8484
public AtomicIntegerSerializer() { super(AtomicInteger.class, false); }
8585

8686
@Override
87-
public void serialize(AtomicInteger value, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonGenerationException {
87+
public void serialize(AtomicInteger value, JsonGenerator gen, SerializerProvider provider) throws IOException {
8888
gen.writeNumber(value.get());
8989
}
9090

@@ -106,7 +106,7 @@ public static class AtomicLongSerializer
106106
public AtomicLongSerializer() { super(AtomicLong.class, false); }
107107

108108
@Override
109-
public void serialize(AtomicLong value, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonGenerationException {
109+
public void serialize(AtomicLong value, JsonGenerator gen, SerializerProvider provider) throws IOException {
110110
gen.writeNumber(value.get());
111111
}
112112

0 commit comments

Comments
 (0)