db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Fisher (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DDLUTILS-190) column.setSize needs to be a bit more robust when trying to convert numbers
Date Thu, 03 Jan 2008 17:31:34 GMT

    [ https://issues.apache.org/jira/browse/DDLUTILS-190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555614#action_12555614
] 

Joe Fisher commented on DDLUTILS-190:
-------------------------------------

sorry, this is for java 1.5, make the following change for 1.4 (default)

// put back in 1.5 _log.warn(String.format("Unable to convert %s to a number or number,scale.
Setting to null", _size), ex);
                _log.warn("Unable to convert " + _size +" to a number or number,scale. Setting
to null", ex);


> column.setSize needs to be a bit more robust when trying to convert numbers
> ---------------------------------------------------------------------------
>
>                 Key: DDLUTILS-190
>                 URL: https://issues.apache.org/jira/browse/DDLUTILS-190
>             Project: DdlUtils
>          Issue Type: Bug
>          Components: Core (No specific database)
>            Reporter: Joe Fisher
>            Assignee: Thomas Dudziak
>
> When the xml file uses the text "null" to describe a null column, the setSize does not
handle this case, I wrapped it in number format exception, and null it out. Added log to column.java
> Below is the patch to fix this issue:
> Index: src/java/org/apache/ddlutils/model/Column.java
> ===================================================================
> --- src/java/org/apache/ddlutils/model/Column.java  (revision 608559)
> +++ src/java/org/apache/ddlutils/model/Column.java  (working copy)
> @@ -29,6 +29,9 @@
>  import org.apache.commons.beanutils.ConvertUtils;
>  import org.apache.commons.lang.builder.EqualsBuilder;
>  import org.apache.commons.lang.builder.HashCodeBuilder;
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +
>  import org.apache.ddlutils.util.Jdbc3Utils;
>  /**
> @@ -41,6 +44,8 @@
>      /** Unique ID for serialization purposes. */
>      private static final long serialVersionUID = -6226348998874210093L;
> +    private static final Log _log = LogFactory.getLog(Column.class);
> +
>      /** The name of the column. */
>      private String _name;
>      /** The java name of the column (optional and unused by DdlUtils, for Torque compatibility).
*/
> @@ -322,16 +327,24 @@
>              int pos = size.indexOf(",");
>              _size  = size;
> -            if (pos < 0)
> +            try
>              {
> +                if (pos < 0)
> +                {
> +                    _scale     = 0;
> +                    _sizeAsInt = new Integer(_size);
> +                }
> +                else
> +                {
> +                    _sizeAsInt = new Integer(size.substring(0, pos));
> +                    _scale     = Integer.parseInt(size.substring(pos + 1));
> +                }
> +            } catch (NumberFormatException ex) {
> +                _log.warn(String.format("Unable to convert %s to a number or number,scale.
Setting to null", _size), ex);
> +                _size      = null;
> +                _sizeAsInt = null;
>                  _scale     = 0;
> -                _sizeAsInt = new Integer(_size);
>              }
> -            else
> -            {
> -                _sizeAsInt = new Integer(size.substring(0, pos));
> -                _scale     = Integer.parseInt(size.substring(pos + 1));
> -            }
>          }
>          else
>          {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message