Skip to content

Commit a6cb030

Browse files
authored
Prep work for #5151 (#5154)
1 parent c7c5bf2 commit a6cb030

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,9 @@ public final Object findInjectableValue(Object valueId,
474474
|| (optional == null && !isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_INJECT_VALUE))) {
475475
return JacksonInject.Value.empty();
476476
}
477-
return reportBadDefinition(ClassUtil.classOf(valueId), String.format(
478-
"No 'injectableValues' configured, cannot inject value with id '%s'", valueId));
477+
throw missingInjectValueException(String.format(
478+
"No 'injectableValues' configured, cannot inject value with id '%s'", valueId),
479+
valueId, forProperty, beanInstance);
479480
}
480481
return _injectableValues.findInjectableValue(valueId, this, forProperty, beanInstance, optional);
481482
}
@@ -2095,6 +2096,16 @@ public JsonMappingException missingTypeIdException(JavaType baseType,
20952096
return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, null);
20962097
}
20972098

2099+
/**
2100+
* @since 2.20
2101+
*/
2102+
public JsonMappingException missingInjectValueException(String msg,
2103+
Object valueId,
2104+
BeanProperty forProperty, Object beanInstance) {
2105+
return InvalidDefinitionException.from(_parser, msg,
2106+
constructType(ClassUtil.classOf(beanInstance)));
2107+
}
2108+
20982109
/*
20992110
/**********************************************************
21002111
/* Other internal methods

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ public Object findInjectableValue(Object valueId, DeserializationContext ctxt,
9696
if (Boolean.FALSE.equals(optional)
9797
|| ((optional == null)
9898
&& ctxt.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_INJECT_VALUE))) {
99-
return ctxt.reportBadDefinition(ClassUtil.classOf(valueId), String.format(
100-
"No injectable value with id '" + key + "' " +
101-
"found (for property '" + forProperty.getName() + "')"));
99+
throw ctxt.missingInjectValueException(
100+
String.format("No injectable value with id '%s' found (for property '%s')",
101+
key, forProperty.getName()),
102+
valueId, forProperty, beanInstance);
102103
}
103104
}
104105
return ob;

0 commit comments

Comments
 (0)