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

                 Key: STS-857
                 URL: http://www.stripesframework.org/jira/browse/STS-857
             Project: Stripes
          Issue Type: Improvement
          Components: Validation
    Affects Versions: Release 1.5.6
            Reporter: John Newman


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?


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to