StringValueConversionException for correct situation
----------------------------------------------------

                 Key: WICKET-4309
                 URL: https://issues.apache.org/jira/browse/WICKET-4309
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.3
         Environment: Java 1.6, Jboss
            Reporter: Ilia Naryzhny


StringValue.toOptionalLong() produces 
org.apache.wicket.util.string.StringValueConversionException if empty string 
was passed.
Let me suggest, that this behavior should be changes for all toOptionalXXX 
methods except getOptionalString method.

The problem in inner code:

The problem in following code:

public final Long toOptionalLong() throws StringValueConversionException
    {
        return (text == null) ? null : toLongObject();
    }

Should be something like this:

The problem in following code:

public final Long toOptionalLong() throws StringValueConversionException
    {
        return Strings.isEmpty() ? null : toLongObject();
    }

But there is another problem: what to do if incorrect param was passed - for 
example "abc" for parameter of Long type?

--
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

        

Reply via email to