Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-582

PropertiesConfigurationLayout.getCanonicalComment throws StringIndexOutOfBoundsException when line before property has a single space

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.10
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      When a properties file has a line with a single space in it, calling getCanonicalComment(<propertyKey>, false) on the PropertiesConfigurationLayout will throw a StringIndexOutOfBoundsException. Below is the stack trace:

      java.lang.StringIndexOutOfBoundsException: String index out of range: 1
      	at java.lang.String.charAt(String.java:686)
      	at org.apache.commons.configuration.PropertiesConfigurationLayout.stripCommentChar(PropertiesConfigurationLayout.java:768)
      	at org.apache.commons.configuration.PropertiesConfigurationLayout.trimComment(PropertiesConfigurationLayout.java:741)
      	at org.apache.commons.configuration.PropertiesConfigurationLayout.constructCanonicalComment(PropertiesConfigurationLayout.java:900)
      	at org.apache.commons.configuration.PropertiesConfigurationLayout.getCanonicalComment(PropertiesConfigurationLayout.java:212)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jonus511 Jonathan wu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: