java.lang.StringIndexOutOfBoundsException in JAXB generation when element name 
is uppercase
-------------------------------------------------------------------------------------------

                 Key: XFIRE-1028
                 URL: http://jira.codehaus.org/browse/XFIRE-1028
             Project: XFire
          Issue Type: Bug
          Components: Generator
    Affects Versions: 1.2.6
            Reporter: Renaud Bruyeron
            Assignee: Dan Diephouse
             Fix For: 1.2.7
         Attachments: patch-test-uppercase-jaxb.txt


The code that performs case-changes on the element name from the WSDL is broken 
is some specific cases, and results in StringIndexOutOfBoundsException being 
thrown by wsgen.

Specifically, here is the faulty code in JAXBSchemaSupport:
{code}
        private String replaceAndUpperCase(StringBuffer local) {
                for (int i = 0; i < local.length(); i++) {
                        char c = local.charAt(i);

                        if (!Character.isDigit(c) && !Character.isLetter(c)) {
                                local.delete(i, i+1);
                                if (i <= local.length()) {
                                        char c2 = local.charAt(i);
                                        local.setCharAt(i, 
Character.toUpperCase(c2));
                                }
                        }
                }

                if (local.length() >= 2) {
                        local.setCharAt(0, 
Character.toLowerCase(local.charAt(0)));
                        for (int i = 1; i < local.length(); i++) {
// This will throw an exception if i = local.length() -1 AND 
Character.isUpperCase(local.charAt(i))
                                if (Character.isUpperCase(local.charAt(i))
                                                && 
Character.isUpperCase(local.charAt(i+1))) {
                                        local.setCharAt(i, 
Character.toLowerCase(local.charAt(i)));
                                } else {
                                        break;
                                }
                        }
                } else {
                        local.setCharAt(0, 
Character.toLowerCase(local.charAt(0)));
                }

                return local.toString();
        }
{code}

Attached is a test-case that shows the problem.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to