[ http://mc4j.org/jira/browse/STS-426?page=comments#action_10836 ]
Alan Burlison commented on STS-426:
-----------------------------------
The offending code is in PropertyExpressionEvaluation.getTypeVariableValue().
It is called by convertToClass() with a type value of 'K', which is the correct
type for the generic that is being processed. However the following loop in
getTypeVariableValue fails to resolve the class properly:
Class lastBean = this.bean.getClass();
for (NodeEvaluation n = evaluation.getPrevious(); n != null;
n=n.getPrevious()) {
if (n.getValueType() instanceof Class) {
lastBean = (Class) n.getValueType();
break;
}
}
That is because in this particular case, n.getValueType() returns
ParameterizedType which is not a Class instance.
It appears that the code assumes that the ActionBean class may be generic, but
that any nested objects are assumed to be concrete Class types, and not
generics.
I'm not quite sure how to fix it though...
> NPE in PropertyExpressionEvaluation.getScalarType with generics
> ---------------------------------------------------------------
>
> Key: STS-426
> URL: http://mc4j.org/jira/browse/STS-426
> Project: Stripes
> Issue Type: Bug
> Components: Validation
> Affects Versions: Release 1.4.3
> Environment: OpemSolaris / Tomcat 5.5.17
> Reporter: Alan Burlison
> Assigned To: Tim Fennell
>
> I have a generic class that is used to store result set scrolling information
> for query pages. Specifically, the class holds the maximum
> and minimum key values for the rows displayed on the page:
> public class ResultPageState<K> {
> // Methods elided
> private K minKey;
> private K maxKey;
> private boolean moreBefore;
> private boolean moreAfter;
> }
> I store an appropriately-typed instance of this class inside my ActionBeans,
> e.g. if the keys are Strings:
> private ResultPageState<String> pageState;
> In the associated JSP I refer to the pageState as follows:
> <ss:hidden name="pageState.minKey"/>
> <ss:hidden name="pageState.maxKey"/>
> <ss:hidden name="pageState.moreBefore"/>
> <ss:hidden name="pageState.moreAfter"/>
> When rendering the page the values are retrieved correctly:
> <input name="pageState.minKey" value="quinn" type="hidden" />
> <input name="pageState.maxKey" value="zach" type="hidden" />
> <input name="pageState.moreBefore" value="true" type="hidden" />
> <input name="pageState.moreAfter" value="false" type="hidden" />
> But during the binding phase of Action submit processing a NPE is thrown:
> 23 Oct 2007 12:54:59,956 DEBUG Could not bind property with name
> [pageState.maxKey] to bean of type: UserSearchAction
> java.lang.NullPointerException
> at
> net.sourceforge.stripes.util.bean.PropertyExpressionEvaluation.getScalarType(PropertyExpressionEvaluation.java:479)
> at
> net.sourceforge.stripes.controller.DefaultActionBeanPropertyBinder.bind(DefaultActionBeanPropertyBinder.java:265)
> at
> net.sourceforge.stripes.controller.DispatcherHelper$3.intercept(DispatcherHelper.java:185)
> at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:157)
> at
> net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:107)
> at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:154)
> at
> net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:73)
> at
> net.sourceforge.stripes.controller.DispatcherHelper.doBindingAndValidation(DispatcherHelper.java:182)
> at
> net.sourceforge.stripes.controller.DispatcherServlet.doBindingAndValidation(DispatcherServlet.java:217)
> at
> net.sourceforge.stripes.controller.DispatcherServlet.doPost(DispatcherServlet.java:142)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> The offending code seems to be in
> net.sourceforge.stripes.util.beanPropertyExpressionEvaluation.convertToClass
> - if it fails to resolve the type to a Class it returns null, and that
> results in the NPE in PropertyExpressionEvaluation.getScalarType. The
> comments on convertToClass seem to suggest that it should cope with generics,
> but in this case it obviously doesn't.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development