[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-978) StringIndexOutOfBoundsException in org.jboss.seam.ui.UISelectDate.commaSeparate(String[] values, int maxLength)

Leszek Kowalski (JIRA) jira-events at lists.jboss.org
Sat Mar 3 07:29:08 EST 2007


StringIndexOutOfBoundsException in org.jboss.seam.ui.UISelectDate.commaSeparate(String[] values, int maxLength)
---------------------------------------------------------------------------------------------------------------

                 Key: JBSEAM-978
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-978
             Project: JBoss Seam
          Issue Type: Bug
          Components: JSF
    Affects Versions: 1.2.0.GA
         Environment: Seam 1.2.0patch1, Jetty 5.1.12, polish locale set in faces-config.xml
            Reporter: Leszek Kowalski


In Polish abbreviation for Sunday is just "N" so val.substring(0,2) fails:

Stacktrace:
java.lang.StringIndexOutOfBoundsException: String index out of range: 2
	at java.lang.String.substring(Unknown Source)
	at org.jboss.seam.ui.UISelectDate.commaSeparate(UISelectDate.java:141)
	at org.jboss.seam.ui.UISelectDate.writeLocaleInformation(UISelectDate.java:118)
	at org.jboss.seam.ui.UISelectDate.writeScript(UISelectDate.java:98)
	at org.jboss.seam.ui.UISelectDate.encodeBegin(UISelectDate.java:70)
        (.....)


The fix is trivial:
          if (!"".equals(val))
          {
             if (sb.length() > 0) sb.append(',');
+          int length = val.length();
+          sb.append(maxLength == -1 ? val : val.substring(0, length < maxLength ? length : maxLength));
-           sb.append(maxLength == -1 ? val : val.substring(0, maxLength));
          }


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

        



More information about the seam-issues mailing list