[
https://issues.apache.org/jira/browse/LANG-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13453898#comment-13453898
]
Wilf Middleton commented on LANG-810:
-------------------------------------
Anyone who know String.substring(start,end) would be familiar with how this
works. However, the Javadoc is not quite as clear with this method.
Also, the reference to end index in the startIndex parameter description
should be removed in its entirety. My suggestion is:
== OLD ==
Parameters:
array - the array of values to join together, may be null
separator - the separator character to use, null treated as ""
startIndex - the first index to start joining from. It is an error to pass in
an end index past the end of the array
endIndex - the index to stop joining from (exclusive). It is an error to pass
in an end index past the end of the array
== NEW ==
Parameters:
array - the array of values to join together, may be null
separator - the separator character to use, null treated as ""
startIndex - the first index to start joining from
endIndex - the index to stop joining from (exclusive). It is an error to pass
in an end index past the end of the array
The number of elements joined equals (endIndex - beginIndex). This will throw
an exception if the endIndex is larger than the length of the array.
That clears it up for me because it clearly describes the condition that will
fail and how to calculate the length as well.
> StringUtils.join() endIndex, bugged for loop
> --------------------------------------------
>
> Key: LANG-810
> URL: https://issues.apache.org/jira/browse/LANG-810
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.1
> Reporter: Krzysztof Nazarewski
> Assignee: Joerg Schaible
> Fix For: 3.2
>
> Attachments: StringUtilsArraysJoinTest.java, StringUtils.java
>
> Original Estimate: 1m
> Remaining Estimate: 1m
>
> endIndex is described as index, but for loop still checks it as "array
> length".
> Basically missing equal sign
> commons-lang3-3.1-sources.jar, StringUtils.java lines 3309, 3394:
> for (int i = startIndex; i < endIndex; i++) {
> should be:
> for (int i = startIndex; i <= endIndex; i++) {
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira