From 3d845a3822978c408bbbe48e02cac7ad7a4d7f07 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 21 Jan 2021 12:09:40 -0800 Subject: [PATCH] Try to reduce usage of `JsonMappingException` (to prepare for #2828) --- .../TestContextualDeserialization.java | 2 -- .../contextual/TestContextualKeyTypes.java | 3 +-- .../contextual/TestContextualSerialization.java | 3 --- .../TestContextualWithAnnDeserializer.java | 1 - .../databind/convert/CoerceToBooleanTest.java | 9 ++------- .../databind/deser/TestBeanDeserializer.java | 2 +- .../jackson/databind/deser/TestConcurrency.java | 8 +------- .../databind/deser/TestCustomDeserializers.java | 4 ++-- .../deser/creators/EnumCreatorTest.java | 6 ++++-- .../deser/creators/NullValueViaCreatorTest.java | 4 ++-- .../creators/TestCustomValueInstDefaults.java | 17 ++++++++--------- .../exc/ExceptionSerializationTest.java | 4 ++-- ...ptionHandlingWithDefaultDeserialization.java | 5 +++-- ...nHandlingWithJsonCreatorDeserialization.java | 5 +++-- .../databind/jsonschema/NewSchemaTest.java | 6 +++--- ...SubtypesExternalPropertyMissingProperty.java | 6 +++--- ...SubtypesExternalPropertyMissingProperty.java | 16 ++++++++-------- .../databind/module/SimpleModuleTest.java | 4 ++-- .../databind/module/TestTypeModifiers.java | 2 -- .../databind/node/NodeContext2049Test.java | 3 ++- .../databind/ser/TestSerializerProvider.java | 5 +++-- .../databind/ser/filter/TestMapFiltering.java | 5 ++--- .../TestNonStaticInnerClassInList32.java | 1 - 23 files changed, 52 insertions(+), 69 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualDeserialization.java index 1f5825ee49..dd44e2120e 100644 --- a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualDeserialization.java +++ b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualDeserialization.java @@ -107,7 +107,6 @@ public StringValue deserialize(JsonParser jp, DeserializationContext ctxt) throw @Override public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { String name = (property == null) ? "NULL" : property.getName(); return new MyContextualDeserializer(name); @@ -137,7 +136,6 @@ public StringValue deserialize(JsonParser jp, DeserializationContext ctxt) throw @Override public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { Name ann = property.getAnnotation(Name.class); if (ann == null) { diff --git a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualKeyTypes.java b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualKeyTypes.java index 7a2644a022..13b40ac8d8 100644 --- a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualKeyTypes.java +++ b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualKeyTypes.java @@ -45,7 +45,6 @@ public void serialize(String value, JsonGenerator jgen, SerializerProvider provi @Override public JsonSerializer createContextual(SerializerProvider prov, BeanProperty property) - throws JsonMappingException { return new ContextualKeySerializer(_prefix+":"); } @@ -70,7 +69,7 @@ public Object deserializeKey(String key, DeserializationContext ctxt) @Override public KeyDeserializer createContextual(DeserializationContext ctxt, - BeanProperty property) throws JsonMappingException + BeanProperty property) { return new ContextualDeser((property == null) ? "ROOT" : property.getName()); } diff --git a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualSerialization.java b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualSerialization.java index 6b57205b50..0e5b01dc28 100644 --- a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualSerialization.java +++ b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualSerialization.java @@ -134,7 +134,6 @@ public void serialize(String value, JsonGenerator jgen, SerializerProvider provi @Override public JsonSerializer createContextual(SerializerProvider prov, BeanProperty property) - throws JsonMappingException { String prefix = "UNKNOWN"; Prefix ann = null; @@ -174,7 +173,6 @@ public void serialize(String value, JsonGenerator jgen, SerializerProvider provi @Override public JsonSerializer createContextual(SerializerProvider prov, BeanProperty property) - throws JsonMappingException { return new ContextualAndResolvable(isResolved, isContextual+1); } @@ -205,7 +203,6 @@ public void serialize(String value, JsonGenerator g, SerializerProvider provider @Override public JsonSerializer createContextual(SerializerProvider prov, BeanProperty property) - throws JsonMappingException { if (property == null) { return new AccumulatingContextual(desc+"/ROOT"); diff --git a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualWithAnnDeserializer.java b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualWithAnnDeserializer.java index e019014b95..24951fe610 100644 --- a/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualWithAnnDeserializer.java +++ b/src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualWithAnnDeserializer.java @@ -54,7 +54,6 @@ public StringValue deserialize(JsonParser p, DeserializationContext ctxt) throws @Override public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { Name ann = property.getAnnotation(Name.class); if (ann == null) { diff --git a/src/test/java/com/fasterxml/jackson/databind/convert/CoerceToBooleanTest.java b/src/test/java/com/fasterxml/jackson/databind/convert/CoerceToBooleanTest.java index 126e20db4a..2f8850ff79 100644 --- a/src/test/java/com/fasterxml/jackson/databind/convert/CoerceToBooleanTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/convert/CoerceToBooleanTest.java @@ -10,12 +10,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.BaseMapTest; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.CoercionAction; import com.fasterxml.jackson.databind.cfg.CoercionInputShape; import com.fasterxml.jackson.databind.exc.MismatchedInputException; @@ -99,7 +94,7 @@ public void testEmptyStringFailForBooleanPrimitive() throws IOException try { reader.readValue(aposToQuotes("{'booleanValue':''}")); fail("Expected failure for boolean + empty String"); - } catch (JsonMappingException e) { + } catch (MismatchedInputException e) { verifyException(e, "Cannot coerce `null` to `boolean`"); verifyException(e, "FAIL_ON_NULL_FOR_PRIMITIVES"); } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestBeanDeserializer.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestBeanDeserializer.java index 98e20007e6..d96a605123 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/TestBeanDeserializer.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestBeanDeserializer.java @@ -113,7 +113,7 @@ public Issue476Deserializer(BeanDeserializer src) { @Override public JsonDeserializer createContextual(DeserializationContext ctxt, - BeanProperty property) throws JsonMappingException { + BeanProperty property) { propCount++; return this; } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestConcurrency.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestConcurrency.java index 8e0267f4d6..66b7cc3ca2 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/TestConcurrency.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestConcurrency.java @@ -11,12 +11,6 @@ */ public class TestConcurrency extends BaseMapTest { - /* - /********************************************** - /* Helper beans - /********************************************** - */ - @JsonDeserialize(using=CustomBeanDeserializer.class) static class Bean { @@ -51,7 +45,7 @@ public Bean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOExc } @Override - public void resolve(DeserializationContext ctxt) throws JsonMappingException + public void resolve(DeserializationContext ctxt) { try { Thread.sleep(100L); diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomDeserializers.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomDeserializers.java index a198f9d4af..eb1601ab92 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomDeserializers.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomDeserializers.java @@ -180,7 +180,7 @@ public Bean375Outer deserialize(JsonParser p, DeserializationContext ctxt) } @Override public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { + { return new Bean375OuterDeserializer(property); } } @@ -211,7 +211,7 @@ public Bean375Inner deserialize(JsonParser p, DeserializationContext ctxt) @Override public JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { + { if (property != null) { Negative n = property.getAnnotation(Negative.class); if (n != null) { diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/EnumCreatorTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/EnumCreatorTest.java index 5024cea2a0..ea7be68143 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/EnumCreatorTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/EnumCreatorTest.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.Deserializers; import com.fasterxml.jackson.databind.deser.std.EnumDeserializer; +import com.fasterxml.jackson.databind.exc.ValueInstantiationException; import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -103,7 +104,8 @@ protected enum TestEnum324 static class DelegatingDeserializers extends Deserializers.Base { @Override - public JsonDeserializer findEnumDeserializer(final Class type, final DeserializationConfig config, final BeanDescription beanDesc) throws JsonMappingException { + public JsonDeserializer findEnumDeserializer(final Class type, final DeserializationConfig config, final BeanDescription beanDesc) + { final Collection factoryMethods = beanDesc.getFactoryMethods(); if (factoryMethods != null) { for (AnnotatedMethod am : factoryMethods) { @@ -255,7 +257,7 @@ public void testExceptionFromCreator() throws Exception try { /*TestEnum324 e =*/ MAPPER.readValue(quote("xyz"), TestEnum324.class); fail("Should throw exception"); - } catch (JsonMappingException e) { + } catch (ValueInstantiationException e) { verifyException(e, "foobar"); } } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/NullValueViaCreatorTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/NullValueViaCreatorTest.java index 2ef70e20da..d0eacb4716 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/NullValueViaCreatorTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/NullValueViaCreatorTest.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.*; +import com.fasterxml.jackson.databind.exc.ValueInstantiationException; public class NullValueViaCreatorTest extends BaseMapTest { @@ -41,7 +42,6 @@ protected static class ContainerDeserializerResolver extends Deserializers.Base @Override public JsonDeserializer findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) - throws JsonMappingException { if (!Contained.class.isAssignableFrom(type.getRawClass())) { return null; @@ -108,7 +108,7 @@ public void testCreatorReturningNull() throws IOException { try { objectMapper.readValue(json, JsonEntity.class); fail("Should not have succeeded"); - } catch (JsonMappingException e) { + } catch (ValueInstantiationException e) { verifyException(e, "JSON creator returned null"); } } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCustomValueInstDefaults.java b/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCustomValueInstDefaults.java index 79edd026a7..5d54ced0e6 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCustomValueInstDefaults.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCustomValueInstDefaults.java @@ -19,7 +19,8 @@ * and {@link PropertyValueBuffer#getParameter(SettableBeanProperty)} methods. */ @SuppressWarnings("serial") -public class TestCustomValueInstDefaults extends BaseTest +public class TestCustomValueInstDefaults + extends BaseMapTest { static class Bucket { @@ -119,10 +120,9 @@ static class BucketInstantiator extends StdValueInstantiator } @Override - public Object createFromObjectWith( - DeserializationContext ctxt, - SettableBeanProperty[] props, - PropertyValueBuffer buffer) throws JsonMappingException + public Object createFromObjectWith(DeserializationContext ctxt, + SettableBeanProperty[] props, PropertyValueBuffer buffer) + throws IOException { int a = Bucket.DEFAULT_A; int b = Bucket.DEFAULT_B; @@ -153,10 +153,9 @@ static class BigBucketInstantiator extends StdValueInstantiator } @Override - public Object createFromObjectWith( - DeserializationContext ctxt, - SettableBeanProperty[] props, - PropertyValueBuffer buffer) throws JsonMappingException + public Object createFromObjectWith(DeserializationContext ctxt, + SettableBeanProperty[] props, PropertyValueBuffer buffer) + throws IOException { int i01 = BigBucket.DEFAULT_I; int i02 = BigBucket.DEFAULT_I; diff --git a/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionSerializationTest.java b/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionSerializationTest.java index bce1f8a64f..2c798b8b88 100644 --- a/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionSerializationTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/exc/ExceptionSerializationTest.java @@ -113,13 +113,13 @@ public void testIgnorals() throws Exception } // [databind#1368] - public void testJsonMappingExceptionSerialization() throws IOException { + public void testDatabindExceptionSerialization() throws IOException { Exception e = null; // cant deserialize due to unexpected constructor try { MAPPER.readValue( "{ \"val\": \"foo\" }", NoSerdeConstructor.class ); fail("Should not pass"); - } catch (JsonMappingException e0) { + } catch (MismatchedInputException e0) { verifyException(e0, "cannot deserialize from Object"); e = e0; } diff --git a/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithDefaultDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithDefaultDeserialization.java index 928b083f23..64af628de6 100644 --- a/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithDefaultDeserialization.java +++ b/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithDefaultDeserialization.java @@ -6,7 +6,8 @@ import java.io.IOException; -public class TestExceptionHandlingWithDefaultDeserialization extends BaseMapTest +public class TestExceptionHandlingWithDefaultDeserialization + extends BaseMapTest { static class Foo { private Bar bar; @@ -38,7 +39,7 @@ public String getQux() { } } - public void testShouldThrowJsonMappingExceptionWithPathReference() throws IOException { + public void testShouldThrowExceptionWithPathReference() throws IOException { // given ObjectMapper mapper = new ObjectMapper(); String input = "{\"bar\":{\"baz\":{qux:\"quxValue\"))}"; diff --git a/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithJsonCreatorDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithJsonCreatorDeserialization.java index 3797c80683..6d59aa85a1 100644 --- a/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithJsonCreatorDeserialization.java +++ b/src/test/java/com/fasterxml/jackson/databind/exc/TestExceptionHandlingWithJsonCreatorDeserialization.java @@ -8,7 +8,8 @@ import java.io.IOException; -public class TestExceptionHandlingWithJsonCreatorDeserialization extends BaseMapTest +public class TestExceptionHandlingWithJsonCreatorDeserialization + extends BaseMapTest { static class Foo { private Bar bar; @@ -49,7 +50,7 @@ public String getQux() { } } - public void testShouldThrowJsonMappingExceptionWithPathReference() throws IOException { + public void testShouldThrowExceptionWithPathReference() throws IOException { // given ObjectMapper mapper = new ObjectMapper(); String input = "{\"bar\":{\"baz\":{qux:\"quxValue\"))}"; diff --git a/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java b/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java index 14acfe1f7d..b4538ac128 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java @@ -130,7 +130,7 @@ public void optionalProperty(BeanProperty prop) throws JsonMappingException { @Override public void optionalProperty(String name, JsonFormatVisitable handler, - JavaType propertyTypeHint) throws JsonMappingException { } + JavaType propertyTypeHint) { } private void _visit(BeanProperty prop) throws JsonMappingException { @@ -315,7 +315,7 @@ public void optionalProperty(BeanProperty prop) throws JsonMappingException { ser.acceptJsonFormatVisitor(new JsonFormatVisitorWrapper.Base() { @Override public JsonNumberFormatVisitor expectNumberFormat( - JavaType t) throws JsonMappingException { + JavaType t) { return new JsonNumberFormatVisitor() { @Override public void format(JsonValueFormat format) { @@ -333,7 +333,7 @@ public void numberType(NumberType numberType) { } @Override - public JsonIntegerFormatVisitor expectIntegerFormat(JavaType t) throws JsonMappingException { + public JsonIntegerFormatVisitor expectIntegerFormat(JavaType t) { return new JsonIntegerFormatVisitor() { @Override public void format(JsonValueFormat format) { diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestPropertyCreatorSubtypesExternalPropertyMissingProperty.java b/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestPropertyCreatorSubtypesExternalPropertyMissingProperty.java index 34f87ef293..6a05bd023f 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestPropertyCreatorSubtypesExternalPropertyMissingProperty.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestPropertyCreatorSubtypesExternalPropertyMissingProperty.java @@ -177,8 +177,8 @@ public void testDeserializationMissing() throws Exception { checkOrangeBoxNull(BOX_READER_PASS, orangeBoxMissingJson); checkAppleBoxNull(BOX_READER_PASS, appleBoxMissingJson); - checkBoxJsonMappingException(BOX_READER_FAIL, orangeBoxMissingJson); - checkBoxJsonMappingException(BOX_READER_FAIL, appleBoxMissingJson); + checkBoxException(BOX_READER_FAIL, orangeBoxMissingJson); + checkBoxException(BOX_READER_FAIL, appleBoxMissingJson); } private void checkOrangeBox(ObjectReader reader) throws Exception { @@ -233,7 +233,7 @@ private void checkAppleBoxNull(ObjectReader reader, String json) throws Exceptio assertNull(deserAppleBox.getFruit()); } - private void checkBoxJsonMappingException(ObjectReader reader, String json) throws Exception { + private void checkBoxException(ObjectReader reader, String json) throws Exception { try { reader.readValue(json); fail("Should not pass"); diff --git a/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestSubtypesExternalPropertyMissingProperty.java b/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestSubtypesExternalPropertyMissingProperty.java index d56fdbe637..c63a1d4082 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestSubtypesExternalPropertyMissingProperty.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsontype/ext/TestSubtypesExternalPropertyMissingProperty.java @@ -167,8 +167,8 @@ public void testDeserializationMissing() throws Exception { checkAppleBoxNull(r, appleBoxMissingJson); r = READER.with(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY); - checkBoxJsonMappingException(r, orangeBoxMissingJson); - checkBoxJsonMappingException(r, appleBoxMissingJson); + checkBoxDatabindException(r, orangeBoxMissingJson); + checkBoxDatabindException(r, appleBoxMissingJson); } /** @@ -177,12 +177,12 @@ public void testDeserializationMissing() throws Exception { @Test public void testDeserializationMissingRequired() throws Exception { ObjectReader r = READER.without(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY); - checkReqBoxJsonMappingException(r, orangeBoxMissingJson); - checkReqBoxJsonMappingException(r, appleBoxMissingJson); + checkReqBoxDatabindException(r, orangeBoxMissingJson); + checkReqBoxDatabindException(r, appleBoxMissingJson); r = READER.with(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY); - checkReqBoxJsonMappingException(r, orangeBoxMissingJson); - checkReqBoxJsonMappingException(r, appleBoxMissingJson); + checkReqBoxDatabindException(r, orangeBoxMissingJson); + checkReqBoxDatabindException(r, appleBoxMissingJson); } private void checkOrangeBox(ObjectReader r) throws Exception { @@ -237,7 +237,7 @@ private void checkAppleBoxNull(ObjectReader r, String json) throws Exception { assertNull(deserAppleBox.fruit); } - private void checkBoxJsonMappingException(ObjectReader r, String json) throws Exception { + private void checkBoxDatabindException(ObjectReader r, String json) throws Exception { try { r.forType(Box.class).readValue(json); fail("Should not pass"); @@ -246,7 +246,7 @@ private void checkBoxJsonMappingException(ObjectReader r, String json) throws Ex } } - private void checkReqBoxJsonMappingException(ObjectReader r, String json) throws Exception { + private void checkReqBoxDatabindException(ObjectReader r, String json) throws Exception { try { r.forType(ReqBox.class).readValue(json, ReqBox.class); fail("Should not pass"); diff --git a/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java b/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java index 674fb6d060..b4d89be924 100644 --- a/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java @@ -45,7 +45,7 @@ public void serialize(CustomBean value, JsonGenerator jgen, SerializerProvider p } @Override - public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { + public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return null; } } @@ -79,7 +79,7 @@ public void serialize(SimpleEnum value, JsonGenerator jgen, SerializerProvider p } @Override - public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { + public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return null; } } diff --git a/src/test/java/com/fasterxml/jackson/databind/module/TestTypeModifiers.java b/src/test/java/com/fasterxml/jackson/databind/module/TestTypeModifiers.java index 279ebbf4ee..bb6cde2c21 100644 --- a/src/test/java/com/fasterxml/jackson/databind/module/TestTypeModifiers.java +++ b/src/test/java/com/fasterxml/jackson/databind/module/TestTypeModifiers.java @@ -59,7 +59,6 @@ public JsonSerializer findCollectionLikeSerializer(SerializationConfig config @Override public JsonDeserializer findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer elementDeserializer) - throws JsonMappingException { if (CollectionMarker.class.isAssignableFrom(type.getRawClass())) { return new MyCollectionDeserializer(); @@ -70,7 +69,6 @@ public JsonDeserializer findCollectionLikeDeserializer(CollectionLikeType typ public JsonDeserializer findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer elementDeserializer) - throws JsonMappingException { if (MapMarker.class.isAssignableFrom(type.getRawClass())) { return new MyMapDeserializer(); diff --git a/src/test/java/com/fasterxml/jackson/databind/node/NodeContext2049Test.java b/src/test/java/com/fasterxml/jackson/databind/node/NodeContext2049Test.java index d29e17f66e..27edc7c1c3 100644 --- a/src/test/java/com/fasterxml/jackson/databind/node/NodeContext2049Test.java +++ b/src/test/java/com/fasterxml/jackson/databind/node/NodeContext2049Test.java @@ -97,7 +97,8 @@ static class ParentSettingDeserializerContextual extends JsonDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) - throws JsonMappingException { + throws JsonMappingException + { JavaType propertyType = property.getType(); JavaType contentType = propertyType; if (propertyType.isCollectionLikeType()) { diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java b/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java index 65366f17fa..0dbad6c3a5 100644 --- a/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java +++ b/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java @@ -1,5 +1,6 @@ package com.fasterxml.jackson.databind.ser; +import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.databind.*; @@ -14,9 +15,9 @@ static class MyBean { static class NoPropsBean { } - public void testFindExplicit() throws JsonMappingException + public void testFindExplicit() throws IOException { - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = newJsonMapper(); SerializationConfig config = mapper.getSerializationConfig(); SerializerFactory f = new BeanSerializerFactory(null); DefaultSerializerProvider prov = new DefaultSerializerProvider.Impl().createInstance(config, f); diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/filter/TestMapFiltering.java b/src/test/java/com/fasterxml/jackson/databind/ser/filter/TestMapFiltering.java index ab2a9a93fb..e82cd1a233 100644 --- a/src/test/java/com/fasterxml/jackson/databind/ser/filter/TestMapFiltering.java +++ b/src/test/java/com/fasterxml/jackson/databind/ser/filter/TestMapFiltering.java @@ -92,13 +92,12 @@ public void serializeAsElement(Object elementValue, JsonGenerator jgen, @Override @Deprecated public void depositSchemaProperty(PropertyWriter writer, - ObjectNode propertiesNode, SerializerProvider provider) - throws JsonMappingException { } + ObjectNode propertiesNode, SerializerProvider provider) { } @Override public void depositSchemaProperty(PropertyWriter writer, JsonObjectFormatVisitor objectVisitor, - SerializerProvider provider) throws JsonMappingException { } + SerializerProvider provider) { } } // [databind#527] diff --git a/src/test/java/com/fasterxml/jackson/failing/TestNonStaticInnerClassInList32.java b/src/test/java/com/fasterxml/jackson/failing/TestNonStaticInnerClassInList32.java index caf3e4806c..eaaab0f7fb 100644 --- a/src/test/java/com/fasterxml/jackson/failing/TestNonStaticInnerClassInList32.java +++ b/src/test/java/com/fasterxml/jackson/failing/TestNonStaticInnerClassInList32.java @@ -41,7 +41,6 @@ public void testInnerList() throws Exception // System.out.println(dogJson); // output: {"name":"Spike","legs":[{length: 5}, {length: 4}]} - // currently throws JsonMappingException Dog2 dogCopy = mapper.readValue(dogJson, Dog2.class); assertEquals(dogCopy.legs.get(1).length, 4); // prefer fully populated Dog instance