Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1292

WordUtils.wrap throws StringIndexOutOfBoundsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.5
    • 3.6
    • None
    • None

    Description

      Running following line of code results in StringIndexOutOfBoundsException (in 3.5 release)

      WordUtils.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",70);
      
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      
      	at java.lang.String.substring(String.java:1967)
      	at org.apache.commons.lang3.text.WordUtils.wrap(WordUtils.java:328)
      	at org.apache.commons.lang3.text.WordUtils.wrap(WordUtils.java:176)
      	at org.apache.commons.lang3.text.WordUtils.wrap(WordUtils.java:100)
      	at pl.netpr.commons.string.TextToolsTest.testWrap(TextToolsTest.java:245)
      	
      

      It worked fine with 3.4 releae.

      Attachments

        Issue Links

          Activity

            People

              dmjones500 Duncan Jones
              mhankus Mirek Hankus
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: