TitleTextUtil.parseIntParameter() fails in case of trailing banks
Date05-Oct-2005 14:28:06 EEST
Version2.2.28
Submitter194.94.56.12
Bug criticalityMediumBug
Browser version
Bug statusClosedBug
PageProvider used
Servlet Container
Operating System
URL
Java version

This bug occures when TextUtil.getIntegerProperty() is used to parse an int value from a Properties object. If the entered value is followed by a trailing blank character (e.g.: '60 ') TextUtil.getIntegerProperty(String value, String defaultValue) returns the defaultValue instead of the specified value.

To fix this, leading and trailing whitespace must be omitted from the parameter string 'value'. Here is my suggestion how to fix this bug in TextUtil.java:

starting at line 298

    /**
     *  Parses an integer parameter, returning a default value
     *  if the value is null or a non-number.
     */

    public static int parseIntParameter( String value, int defvalue )
    {
        int val = defvalue;
        
        try
        {
            val = Integer.parseInt( value.trim() );
        }
        catch( Exception e ) {
        }
        return val;
    }

reported by Andreas Kohlbecker


Confirmed. Urgh, these trailing blanks...

-- JanneJalkanen


Fixed in 2.3.31

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-4) was last changed on 16-Oct-2005 13:59 by Administrator