From 05647d46e9ac2bf674b320e8467616aa72954f3e Mon Sep 17 00:00:00 2001 From: pascalschumacher Date: Fri, 4 Nov 2016 17:20:56 +0100 Subject: [PATCH] LANG-1281: Javadoc of StringUtils.ordinalIndexOf is contradictory (closes #205) --- src/changes/changes.xml | 1 + src/main/java/org/apache/commons/lang3/StringUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b2a886ffe..955c4a261 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -46,6 +46,7 @@ The type attribute can be add,update,fix,remove. + Javadoc of StringUtils.ordinalIndexOf is contradictory. Wrong name or result of StringUtils#getJaroWinklerDistance StringUtils#join(T...): warning: [unchecked] Possible heap pollution from parameterized vararg type T Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible. diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 828f4c64b..0d37d7070 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -1394,10 +1394,10 @@ public class StringUtils { *

Finds the n-th index within a CharSequence, handling {@code null}. * This method uses {@link String#indexOf(String)} if possible.

*

Note: The code starts looking for a match at the start of the target, - * incrementing the starting index by one after each successful match.

- *

The code increments the starting index by one, - * rather than by the length of the match string, - * so matches may overlap.

+ * incrementing the starting index by one after each successful match + * (unless {@code searchStr} is an empty string in which case the position + * is never incremented and {@code 0} is returned immediately). + * This means that matches may overlap.

*

A {@code null} CharSequence will return {@code -1}.

* *