Skip to content

Commit 2449fd5

Browse files
committed
Minor clean up for error messages
1 parent f0ef5cd commit 2449fd5

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.databind.deser.impl.ValueInjector;
1111
import com.fasterxml.jackson.databind.introspect.*;
1212
import com.fasterxml.jackson.databind.util.Annotations;
13+
import com.fasterxml.jackson.databind.util.ClassUtil;
1314

1415
/**
1516
* Builder class used for aggregating deserialization information about
@@ -404,7 +405,7 @@ public JsonDeserializer<?> buildBuilderBased(JavaType valueType, String expBuild
404405
if (!expBuildMethodName.isEmpty()) {
405406
_context.reportBadDefinition(_beanDesc.getType(),
406407
String.format("Builder class %s does not have build method (name: '%s')",
407-
_beanDesc.getBeanClass().getName(),
408+
ClassUtil.getTypeDescription(_beanDesc.getType()),
408409
expBuildMethodName));
409410
}
410411
} else {
@@ -415,10 +416,10 @@ public JsonDeserializer<?> buildBuilderBased(JavaType valueType, String expBuild
415416
&& !rawBuildType.isAssignableFrom(rawValueType)
416417
&& !rawValueType.isAssignableFrom(rawBuildType)) {
417418
_context.reportBadDefinition(_beanDesc.getType(),
418-
String.format("Build method '%s' has wrong return type (%s), not compatible with POJO type (%s)",
419+
String.format("Build method `%s` has wrong return type (%s), not compatible with POJO type (%s)",
419420
_buildMethod.getFullName(),
420-
rawBuildType.getName(),
421-
valueType.getRawClass().getName()));
421+
ClassUtil.getClassDescription(rawBuildType),
422+
ClassUtil.getTypeDescription(valueType)));
422423
}
423424
}
424425
// And if so, we can try building the deserializer

src/main/java/com/fasterxml/jackson/databind/deser/std/EnumSetDeserializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ public AccessPattern getEmptyAccessPattern() {
165165
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
166166
BeanProperty property) throws JsonMappingException
167167
{
168+
// 07-May-2020, tatu: Is the argument `EnumSet.class` correct here?
169+
// In a way seems like it should rather refer to value class... ?
170+
// (as it's individual value of element type, not Container)...
168171
final Boolean unwrapSingle = findFormatFeature(ctxt, property, EnumSet.class,
169172
JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
170173
JsonDeserializer<?> deser = _enumDeserializer;

src/main/java/com/fasterxml/jackson/databind/deser/std/ObjectArrayDeserializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
119119
BeanProperty property) throws JsonMappingException
120120
{
121121
JsonDeserializer<?> valueDeser = _elementDeserializer;
122+
// 07-May-2020, tatu: Is the argument `containerType.getRawClass()` right here?
123+
// In a way seems like it should rather refer to value class... ?
124+
// (as it's individual value of element type, not Container)...
122125
Boolean unwrapSingle = findFormatFeature(ctxt, property, _containerType.getRawClass(),
123126
JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
124127
// May have a content converter

src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderErrorHandling.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testUnknownProperty() throws Exception
5454
MAPPER.readValue(json, ValueClassXY.class);
5555
fail("Should not pass");
5656
} catch (MismatchedInputException e) {
57-
verifyException(e, "unrecognized field");
57+
verifyException(e, "Unrecognized field");
5858
}
5959
// but pass if ok to ignore
6060
ValueClassXY result = MAPPER.readerFor(ValueClassXY.class)

src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderFailTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public void testBuilderMethodReturnInvalidType() throws Exception
7070
MAPPER.readValue(json, ValueClassWrongBuildType.class);
7171
fail("Missing expected InvalidDefinitionException exception");
7272
} catch (InvalidDefinitionException e) {
73-
verifyException(e, "Build method");
73+
verifyException(e, "Build method ");
74+
verifyException(e, "#build(0 params)");
7475
verifyException(e, "has wrong return type");
7576
}
7677
}

0 commit comments

Comments
 (0)