in http-core/src/main/scala/com/twitter/finatra/http/marshalling/MessageInjectableValues.scala [110:155]
private[this] def handle(
valueId: Any,
context: DeserializationContext,
forProperty: BeanProperty,
beanInstance: Any,
fieldName: String,
request: Request
): AnyRef = {
try {
if (isRequest(forProperty)) {
request
} else if (Annotations.hasAnnotation(forProperty, requestParamsAnnotations)) {
if (forProperty.getType.isCollectionLikeType) {
request.params.getAll(fieldName) match {
case propertyValue: Seq[String]
if propertyValue.nonEmpty || request.params.contains(fieldName) =>
val separatedValues = handleCommaSeparatedLists(forProperty, fieldName, propertyValue)
val value = handleEmptySeq(forProperty, separatedValues)
val modifiedParamsValue = handleExtendedBooleans(forProperty, value)
convert(context, forProperty, modifiedParamsValue)
case _ => null
}
} else {
request.params.get(fieldName) match {
case Some(value) =>
val modifiedParamsValue = handleExtendedBooleans(forProperty, value)
convert(context, forProperty, modifiedParamsValue)
case _ => null
}
}
} else if (forProperty.getContextAnnotation(classOf[Header]) != null) {
getHeader(context, forProperty, fieldName, request)
} else {
// handle if the field is annotated with an injection annotation
super.findInjectableValue(valueId, context, forProperty, beanInstance)
}
} catch {
// Only translate `InvalidDefinitionException` to InjectableValuesException,
// all others escape to be handled elsewhere.
case ex: InvalidDefinitionException =>
logger.debug(ex.getMessage, ex)
throw InjectableValuesException(
forProperty.getMember.getDeclaringClass,
forProperty.getName)
}
}