[
https://issues.apache.org/jira/browse/WW-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13140006#comment-13140006
]
shenjc commented on WW-3695:
----------------------------
thanks for replying, here provide a simple test case bellow:
@Namespace("/test")
public class TestSimpleAction extends ActionSupport {
private static final long serialVersionUID = 1957094271415003053L;
protected transient Logger logger = LoggerFactory.getLogger(getClass());
private Integer param1;
public Integer getParam1() {
return param1;
}
public void setParam1(Integer param1) {
this.param1 = param1;
}
@Action(value="test1",
results={@Result(name="success",
location="/WEB-INF/pages/test/testSimple.ftl", type="freemarker"),
@Result(name="error",location="/WEB-INF/pages/test/test_error.ftl",
type="freemarker" )}
)
public String test1() {
return SUCCESS;
}
}
when param1=1234567890
http://localhost/test/test1.do?param1=1234567890 execute correct;
but when when param1=2234567890
http://localhost/test/test1.do?param1=2234567890 there are some error:
DEBUG ny.xwork2.conversion.impl.XWorkConverter(72) -unable to convert value
using type converter
[com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
Overflow or underflow casting: "2634567890" into class java.lang.Long -
[unknown location]
at
com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToNumber(XWorkBasicConverter.java:431)
at
com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToNumber(XWorkBasicConverter.java:440)
at
com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:130)
at
com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:334)
at
com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:39)
at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1060)
...
...
WARN .opensymphony.xwork2.ognl.OgnlValueStack(60) -Error setting expression
'param1' with value '[Ljava.lang.String;@1d1a35e'
ognl.MethodFailedException: Method "setParam1" failed for object
cn.test.web.TestSimpleAction@150dcd3 [java.lang.NoSuchMethodException:
cn.test.web.TestSimpleAction.setParam1([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1285)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
...
...
ERROR org.apache.struts2.dispatcher.Dispatcher(38) -Could not find action or
result
/test/test1.do?param1=2634567890
No result defined for action cn.test.web.TestSimpleAction and result input
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
...
...
The exception are catched in XWorkConverter, so that I only can get the
error:"No result defined for action cn.test.web.TestSimpleAction and result
input" ,but can't get original reason:the number is too large;
additional,log "Overflow or underflow casting: "2634567890" into class
java.lang.Long " is printed with DEBUG level ,not WARN or ERROR?
> XWorkConverter catch XWorkException so that the client application can't get
> the detail original error message
> --------------------------------------------------------------------------------------------------------------
>
> Key: WW-3695
> URL: https://issues.apache.org/jira/browse/WW-3695
> Project: Struts 2
> Issue Type: Improvement
> Components: Other
> Affects Versions: 2.2.1.1
> Reporter: shenjc
>
> in com.opensymphony.xwork2.conversion.impl.XWorkConverter line 331 to 341
> {code}
> try {
> if (LOG.isDebugEnabled())
> LOG.debug("falling back to default type converter [" +
> defaultTypeConverter + "]");
> return defaultTypeConverter.convertValue(context, target, member,
> property, value, toClass);
> } catch (Exception e) {
> if (LOG.isDebugEnabled())
> LOG.debug("unable to convert value using type converter [#0]", e,
> defaultTypeConverter.getClass().getName());
> handleConversionException(context, property, value, target);
> return TypeConverter.NO_CONVERSION_POSSIBLE;
> }
> {code}
> here try catch code "defaultTypeConverter.convertValue" so that it can not
> throw exception to outside.
> in some case,for example:
> when I transmit a param a bigInteger to Integer in a action.
> the program will run pass and ignore this exception,the outside program can't
> catch it ,so that can't find what cause the error.
> and it only print in log file:
> {noformat}
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger.debug(72) | unable
> to convert value using type converter
> [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter]
> Overflow or underflow casting: "3322333330" into class java.lang.Long -
> [unknown location]
> {noformat}
> and we need to find this error message in large debug log message;
>
> I think, throw this exception and not catch it here,and change log level from
> debug to error when print this message will better,isn't it ?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira