Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ACDCDC27C for ; Sat, 8 Jun 2013 19:30:20 +0000 (UTC) Received: (qmail 29827 invoked by uid 500); 8 Jun 2013 19:30:20 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 29796 invoked by uid 500); 8 Jun 2013 19:30:20 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 29788 invoked by uid 99); 8 Jun 2013 19:30:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jun 2013 19:30:20 +0000 Date: Sat, 8 Jun 2013 19:30:20 +0000 (UTC) From: "Maurizio Cucchiara (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-3732) XWorkBasicConverter with BigDecimal; trim input as in extended class: DefaultTypeConverter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-3732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13678825#comment-13678825 ] Maurizio Cucchiara commented on WW-3732: ---------------------------------------- Is it still an issue? IIUC now it works: {code:java} public class DefaultTypeConverterTest { @Test public void testBigIntValue() throws Exception { BigInteger b = DefaultTypeConverter.bigIntValue(" 123"); assertEquals(BigInteger.valueOf(123), b); } } {code} > XWorkBasicConverter with BigDecimal; trim input as in extended class: DefaultTypeConverter > ------------------------------------------------------------------------------------------ > > Key: WW-3732 > URL: https://issues.apache.org/jira/browse/WW-3732 > Project: Struts 2 > Issue Type: Bug > Reporter: Kevin Biesbrock > Fix For: 2.3.16 > > > When a value for a parameter of type `BigDecimal` is converted by `XWorkBasicConverter` (this is default Struts2 behavior), a failure occurs when there is a space in the value. The parent to `XWorkBasicConverter`, `DefaultTypeConverter`, has a `stringValue` method that could could be used instead of immediately casting to a String, e.g., `new BigDecimal((String) value)`, which is what ultimately appears to cause a `NumberFormatException` to be thrown from the `BigDecimal` constructor when there is a space in the value. > For example, in version 2.2.3.1, the following lines could be changed as indicated: > 403: return new BigDecimal(stringValue(value, true)); > 405: return new BigInteger(stringValue(value, true)); > 408: String stringValue = stringValue(value, true); > 414: String stringValue = stringValue(value, true); > In fact, at the end of the doConvertToNumber method (where the previous lines reside), as a catch-all, the parameters are passed to the DefaultTypeConverter's `convertValue` method which calls the `bigDecValue` method which calls the `stringValue` method (when all the conditionals align). -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira