commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan wu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CONFIGURATION-582) PropertiesConfigurationLayout.getCanonicalComment throws StringIndexOutOfBoundsException when line before property has a single space
Date Wed, 18 Jun 2014 05:10:03 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14034828#comment-14034828
] 

Jonathan wu commented on CONFIGURATION-582:
-------------------------------------------

I think this is rooted in the fact that PropertiesConfiguration.isCommentLine(line) returns
true if the line is blank, but PropertiesConfigurationLayout.stripCommentChar() assumes comment
lines always contain comment chars. There's no length check while trying to match a comment
char so you get the error. 

> PropertiesConfigurationLayout.getCanonicalComment throws StringIndexOutOfBoundsException
when line before property has a single space
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-582
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-582
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.10
>            Reporter: Jonathan wu
>            Priority: Minor
>
> 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:
> {code}
> 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)
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message