DefaultActionPropertyBinder - type conversion exceptions are just logged as a warning, should optionally be rethrown

Description

DefaultActionBeanPropertyBinder

line 730

protected List<Object> convert(ActionBean bean, ParameterName propertyName, String[] values,
Class<?> declaredType, Class<?> scalarType,
ValidationMetadata validationInfo, List<ValidationError> errors) {

// huge method

line 781
try {
// huge try block
}

line 810
catch (Exception e) {
log.warn(e, "Looks like type converter ", converter, " threw an exception.");
}

Well, that isn't what I expected. If a type converter has a defect and is throwing exceptions all over the place, I would like to know about it through the ExceptionHandler. Logging a warning is fine, but I'd like to have it rethrown right there. In the spirit of backwards compatibility it might be better to have an optional hook,

protected void handleTypeConverterException(ActionBean bean, ParameterName propertyName, String[] values,
Class<?> declaredType, Class<?> scalarType,
ValidationMetadata validationInfo, List<ValidationError> errors, Exception e) {
// subclass this
}

here I could wire in my own code to wrap in a RuntimeException and rethrow [or whatever]. In my case I am _trying to throw a checked exception from a type converter, and hoping it will get caught by the ExceptionHandler which will then take care of it properly. But I can't get anything besides a warning in the log.

And in general, this binder class is really not very subclassable. There's mostly just very long methods (..that were declared as protected .. not private), and there's no real usable hooks for a subclass to come in and customize small aspects of its behavior. And if you think about it, this would be one of the more valuable classes to be able to customize, but you can't do it unless you're comfortable lifting large chunks of code from the superclass.

A patch for the exception hook is attached... i'd like to continue on breaking this class up into more manageable chunks. Any thoughts?

Environment

None

Status

Assignee

Unassigned

Reporter

JohnJ

Labels

None

Tester

None

Components

Affects versions

Release 1.5.6

Priority

Major
Configure