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.