Skip to content

allow missing build method if its name is empty "" #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,13 @@ public JsonDeserializer<?> buildBuilderBased(JavaType valueType,
String expBuildMethodName)
{
// First: validation; must have build method that returns compatible type
if (_buildMethod == null) {
// ("" means you don't need a build method, just cast the last builder)
if (_buildMethod == null && !"".equals(expBuildMethodName)) {
throw new IllegalArgumentException("Builder class "+_beanDesc.getBeanClass().getName()
+" does not have build method '"+expBuildMethodName+"()'");
}

if(_buildMethod != null) {
// also: type of the method must be compatible
Class<?> rawBuildType = _buildMethod.getRawReturnType();
Class<?> rawValueType = valueType.getRawClass();
Expand All @@ -382,6 +385,7 @@ public JsonDeserializer<?> buildBuilderBased(JavaType valueType,
+" has bad return type ("+rawBuildType.getName()
+"), not compatible with POJO type ("+valueType.getRawClass().getName()+")");
}
}
// And if so, we can try building the deserializer
Collection<SettableBeanProperty> props = _properties.values();
BeanPropertyMap propertyMap = BeanPropertyMap.construct(props, _caseInsensitivePropertyComparison);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected BeanAsArrayBuilderDeserializer asArrayDeserializer() {
protected final Object finishBuild(DeserializationContext ctxt, Object builder)
throws IOException
{
if(null==_buildMethod) return builder;
try {
return _buildMethod.getMember().invoke(builder);
} catch (Exception e) {
Expand Down