[jira] [Commented] (JXPATH-188) Ancestor: not reverse axis in case of org.w3c.dom documents
[ https://issues.apache.org/jira/browse/JXPATH-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15052394#comment-15052394 ] Stefan Albrecht commented on JXPATH-188: Some clarification from specification on w3.org - about whether ancestor is indeed reverse axis: XPATH 1.0: http://www.w3.org/TR/xpath/#predicates (Section 2.4) (...)Thus, the ancestor, ancestor-or-self, preceding, and preceding-sibling axes are reverse axes; all other axes are forward axes (...) XPATH 3.1: http://www.w3.org/TR/xpath-31/#prod-xpath31-ReverseAxis ReverseAxis ::= ("parent" "::") | ("ancestor" "::") | ("preceding-sibling" "::") | ("preceding" "::")| ("ancestor-or-self" "::") (and: sorry for causing efforts due to junit 4 tests...) > Ancestor: not reverse axis in case of org.w3c.dom documents > --- > > Key: JXPATH-188 > URL: https://issues.apache.org/jira/browse/JXPATH-188 > Project: Commons JXPath > Issue Type: Bug >Affects Versions: 1.3 >Reporter: Stefan Albrecht > Attachments: AncestorTest.java, AncestorTest.java > > > XPath specifies the ancestor axis to be a reverse axis, thus I would expect > that JXPath delivers results along the reverse axis. This works, if applied > to a context wrapping a poje, but not if the context wraps an org.w3c.dom > document. > I attached a JUnit test for this (but, unluckily, not a patch...) -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (LANG-1193) ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0)
Qin Li created LANG-1193: Summary: ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0) Key: LANG-1193 URL: https://issues.apache.org/jira/browse/LANG-1193 Project: Commons Lang Issue Type: Bug Affects Versions: 3.4 Environment: OS X Yosemite 10.10.5. Maven project. Reporter: Qin Li Fix For: 2.6 In Apache Commons Lang 3.4, StringUtils.ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0)。but StringUtils.ordinalIndexOf("abc", "a", 1) gives correct answer of 0. Based on the above mentioned observation, the bug occurrs if the searchStr is of length > 1, and locates at the index 0 of the str. In Apache Commons Lang 2.6, this bug is not observed. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Reopened] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb reopened LANG-1077: Assignee: (was: Bruno P. Kinoshita) The patch that was applied was wrong. The problem is that one cannot subtract the search length each time, unless one allows for this in the initial index. This is why the initial index is set to str.len (i.e. max index +1) or -1 (min index -1); then the first time through the loop, the original code starts at the end or start respectively. The patched code now fails to start searching at the beginning when the search string len > 1, see LANG-1193 > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Fix For: 3.4 > > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15052734#comment-15052734 ] Sebb commented on LANG-1077: On further reflection, I think the original bug report was wrong, and the original code is correct. The original code steps through the search target one char at a time, so I think the behaviour should be: StringUtils.ordinalIndexOf("aa", "aa", 1) => 0 // matches "aa" StringUtils.ordinalIndexOf("aa", "aa", 2) => 1 // matches ".aa" However if overlapping matches are not allowed, I would expect: StringUtils.ordinalIndexOf("aa", "aa", 2) => 2 // matches "..aa" I have no idea why it was ever expected that the result should be "3", unless it was thought that the index started at 1. Perhaps the OP expected overlapping matches to be disallowed. However there is no indication that this was ever intended. The fix needs to be reverted, and the Javadoc updated to make it clear that overlapping matches are allowed. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Fix For: 3.4 > > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1193) ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0)
[ https://issues.apache.org/jira/browse/LANG-1193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15052771#comment-15052771 ] Sebb commented on LANG-1193: Thanks for the report. I agree that there is a bug here. Looks like the problem was introduced as a fix for LANG-1077 (which was invalid). > ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer > should be 0) > > > Key: LANG-1193 > URL: https://issues.apache.org/jira/browse/LANG-1193 > Project: Commons Lang > Issue Type: Bug >Affects Versions: 3.4 > Environment: OS X Yosemite 10.10.5. Maven project. >Reporter: Qin Li > Fix For: 2.6 > > > In Apache Commons Lang 3.4, StringUtils.ordinalIndexOf("abc", "ab", 1) gives > incorrect answer of -1 (correct answer should be 0)。but > StringUtils.ordinalIndexOf("abc", "a", 1) gives correct answer of 0. > Based on the above mentioned observation, the bug occurrs if the searchStr is > of length > 1, and locates at the index 0 of the str. > In Apache Commons Lang 2.6, this bug is not observed. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (LANG-1193) ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0)
[ https://issues.apache.org/jira/browse/LANG-1193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb resolved LANG-1193. Resolution: Fixed Fix Version/s: (was: 2.6) 3.5 LANG-1193 ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer should be 0) Revert LANG-1077 Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/d75fe46b Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/d75fe46b Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/d75fe46b Branch: refs/heads/master Commit: d75fe46b8f1b0d5c27887052ee4714d6a9c7ea4b Parents: 15e1ea2 Author: Sebb Authored: Fri Dec 11 13:41:22 2015 + Committer: Sebb Committed: Fri Dec 11 13:41:22 2015 + -- src/changes/changes.xml| 2 +- .../java/org/apache/commons/lang3/StringUtils.java | 15 --- .../lang3/StringUtilsEqualsIndexOfTest.java| 17 +++-- 3 files changed, 28 insertions(+), 6 deletions(-) -- > ordinalIndexOf("abc", "ab", 1) gives incorrect answer of -1 (correct answer > should be 0) > > > Key: LANG-1193 > URL: https://issues.apache.org/jira/browse/LANG-1193 > Project: Commons Lang > Issue Type: Bug >Affects Versions: 3.4 > Environment: OS X Yosemite 10.10.5. Maven project. >Reporter: Qin Li > Fix For: 3.5 > > > In Apache Commons Lang 3.4, StringUtils.ordinalIndexOf("abc", "ab", 1) gives > incorrect answer of -1 (correct answer should be 0)。but > StringUtils.ordinalIndexOf("abc", "a", 1) gives correct answer of 0. > Based on the above mentioned observation, the bug occurrs if the searchStr is > of length > 1, and locates at the index 0 of the str. > In Apache Commons Lang 2.6, this bug is not observed. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb resolved LANG-1077. Resolution: Invalid Fix Version/s: (was: 3.4) Revert LANG-1077 Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/d75fe46b Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/d75fe46b Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/d75fe46b Branch: refs/heads/master Commit: d75fe46b8f1b0d5c27887052ee4714d6a9c7ea4b Parents: 15e1ea2 Author: Sebb Authored: Fri Dec 11 13:41:22 2015 + Committer: Sebb Committed: Fri Dec 11 13:41:22 2015 + -- src/changes/changes.xml| 2 +- .../java/org/apache/commons/lang3/StringUtils.java | 15 --- .../lang3/StringUtilsEqualsIndexOfTest.java| 17 +++-- 3 files changed, 28 insertions(+), 6 deletions(-) -- > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053018#comment-15053018 ] haiyang li commented on LANG-1077: -- Sebb, The original bug is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2. somehow title was changed: "StringUtils.ordinalIndexOf("aa", "aa", 2) != 2 in StringUtils" to "StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 And wrong patch was merged into trunk. The right code should be: -- private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) { if (str == null || searchStr == null || ordinal <= 0) { return INDEX_NOT_FOUND; } if (searchStr.length() == 0) { return lastIndex ? str.length() : 0; } final int searchStrLen = searchStr.length(); int index = lastIndex ? str.length() : 0; for (int found = 0; index >= 0;) { if (lastIndex) { index = CharSequenceUtils.lastIndexOf(str, searchStr, index); } else { index = CharSequenceUtils.indexOf(str, searchStr, index); } if (index < 0) { return INDEX_NOT_FOUND; } if (++found >= ordinal) { break; } index = lastIndex ? index - searchStrLen : index + searchStrLen; } return index; } -- please look into the original code. This is a valid bug. It's can't be correct by just updating java doc. because it may confuse people. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > r
[jira] [Commented] (JXPATH-188) Ancestor: not reverse axis in case of org.w3c.dom documents
[ https://issues.apache.org/jira/browse/JXPATH-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053036#comment-15053036 ] Michele Vivoda commented on JXPATH-188: --- No problem at all for the test. Interesting that now parent is a reverse axes, it must be needed now for something, since for XPath I have read that for one-node axes it does not matter whether they are reverse or not. I found why selectSingleNode is wrong in JXPath, it does not consider that with reverse axes must iterate all items and get the last, instead of just getting the first. Probably this happened because it is what one (you, me) expects and is more efficient, but is not how the others (JAXP) work. I also found out that {{getDocumentOrder()}} is not implemented on some reverse axes where it probably should. These changes are complex, break some tests and I am still not sure about their consequences, still working on them.. > Ancestor: not reverse axis in case of org.w3c.dom documents > --- > > Key: JXPATH-188 > URL: https://issues.apache.org/jira/browse/JXPATH-188 > Project: Commons JXPath > Issue Type: Bug >Affects Versions: 1.3 >Reporter: Stefan Albrecht > Attachments: AncestorTest.java, AncestorTest.java > > > XPath specifies the ancestor axis to be a reverse axis, thus I would expect > that JXPath delivers results along the reverse axis. This works, if applied > to a context wrapping a poje, but not if the context wraps an org.w3c.dom > document. > I attached a JUnit test for this (but, unluckily, not a patch...) -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053018#comment-15053018 ] haiyang li edited comment on LANG-1077 at 12/11/15 5:12 PM: Sebb, The original bug is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2. somehow title was changed: "StringUtils.ordinalIndexOf("aa", "aa", 2) != 2 in StringUtils" to "StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 And wrong patch was merged into trunk. The right code should be: -- private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) { if (str == null || searchStr == null || ordinal <= 0) { return INDEX_NOT_FOUND; } if (searchStr.length() == 0) { return lastIndex ? str.length() : 0; } final int searchStrLen = searchStr.length(); int index = lastIndex ? str.length() : 0; for (int found = 0; index >= 0;) { if (lastIndex) { index = CharSequenceUtils.lastIndexOf(str, searchStr, index); } else { index = CharSequenceUtils.indexOf(str, searchStr, index); } if (index < 0) { return INDEX_NOT_FOUND; } if (++found >= ordinal) { break; } index = lastIndex ? index - searchStrLen : index + searchStrLen; } return index; } -- please look into the original code. This is a valid bug. It's can't be correct by just updating java doc. because it may confuse people. BTW, the bug was reported on 12/11/2014, today is 12/11/15 was (Author: lihy70): Sebb, The original bug is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2. somehow title was changed: "StringUtils.ordinalIndexOf("aa", "aa", 2) != 2 in StringUtils" to "StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 And wrong patch was merged into trunk. The right code should be: -- private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) { if (str == null || searchStr == null || ordinal <= 0) { return INDEX_NOT_FOUND; } if (searchStr.length() == 0) { return lastIndex ? str.length() : 0; } final int searchStrLen = searchStr.length(); int index = lastIndex ? str.length() : 0; for (int found = 0; index >= 0;) { if (lastIndex) { index = CharSequenceUtils.lastIndexOf(str, searchStr, index); } else { index = CharSequenceUtils.indexOf(str, searchStr, index); } if (index < 0) { return INDEX_NOT_FOUND; } if (++found >= ordinal) { break; } index = lastIndex ? index - searchStrLen : index + searchStrLen; } return index; } -- please look into the original code. This is a valid bug. It's can't be correct by just updating java doc. because it may confuse people. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { >
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053099#comment-15053099 ] Sebb commented on LANG-1077: bq. The original bug is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2. Sorry, but that is wrong. The code returns *all* matches, so the first match is "aa", i.e. index 0. The second match is ".aa...", i.e. index 1. Third match would be "..aa..", i.e. index 2. etc. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (LANG-1192) FastDateFormat does not support the week-year component (uppercase 'Y')
[ https://issues.apache.org/jira/browse/LANG-1192?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb updated LANG-1192: --- Affects Version/s: (was: 3.5) 3.4 > FastDateFormat does not support the week-year component (uppercase 'Y') > --- > > Key: LANG-1192 > URL: https://issues.apache.org/jira/browse/LANG-1192 > Project: Commons Lang > Issue Type: Bug > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Dominik Stadler > > The Java SimpleDateFormat supports two year-components, 'y' for normal year > and 'Y' for 'Week year', see > http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html > However when we try to use FastDateFormat to parse a format which uses the > week-year, it fails with an exception > {noformat} > java.lang.IllegalArgumentException: Illegal pattern component: > at > org.apache.commons.lang3.time.FastDatePrinter.parsePattern(FastDatePrinter.java:282) > at > org.apache.commons.lang3.time.FastDatePrinter.init(FastDatePrinter.java:149) > at > org.apache.commons.lang3.time.FastDatePrinter.(FastDatePrinter.java:142) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:384) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:369) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:91) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:88) > at > org.apache.commons.lang3.time.FormatCache.getInstance(FormatCache.java:82) > at > org.apache.commons.lang3.time.FastDateFormat.getInstance(FastDateFormat.java:119) > {noformat} > Simple unit test to reproduce this: > {code} > @Test > public void testCommonsLang() { > Date date = new Date(); > Format dateFormat = new SimpleDateFormat(""); > assertNotNull(dateFormat.format(date)); > dateFormat = FastDateFormat.getInstance(""); > assertNotNull(dateFormat.format(date)); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053124#comment-15053124 ] haiyang li commented on LANG-1077: -- Sebb, It doesn't make sense. take a few minutes to think about the definition/contract of "indexOf", and consider "searchStr" as whole object, no matter it's "aa", or "ab". > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1192) FastDateFormat does not support the week-year component (uppercase 'Y')
[ https://issues.apache.org/jira/browse/LANG-1192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053127#comment-15053127 ] Sebb commented on LANG-1192: Comparison with http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html shows that Java 7 added 'X', 'Y' and 'u'. Only 'X' has been implemented so far. > FastDateFormat does not support the week-year component (uppercase 'Y') > --- > > Key: LANG-1192 > URL: https://issues.apache.org/jira/browse/LANG-1192 > Project: Commons Lang > Issue Type: Bug > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Dominik Stadler > > The Java SimpleDateFormat supports two year-components, 'y' for normal year > and 'Y' for 'Week year', see > http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html > However when we try to use FastDateFormat to parse a format which uses the > week-year, it fails with an exception > {noformat} > java.lang.IllegalArgumentException: Illegal pattern component: > at > org.apache.commons.lang3.time.FastDatePrinter.parsePattern(FastDatePrinter.java:282) > at > org.apache.commons.lang3.time.FastDatePrinter.init(FastDatePrinter.java:149) > at > org.apache.commons.lang3.time.FastDatePrinter.(FastDatePrinter.java:142) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:384) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:369) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:91) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:88) > at > org.apache.commons.lang3.time.FormatCache.getInstance(FormatCache.java:82) > at > org.apache.commons.lang3.time.FastDateFormat.getInstance(FastDateFormat.java:119) > {noformat} > Simple unit test to reproduce this: > {code} > @Test > public void testCommonsLang() { > Date date = new Date(); > Format dateFormat = new SimpleDateFormat(""); > assertNotNull(dateFormat.format(date)); > dateFormat = FastDateFormat.getInstance(""); > assertNotNull(dateFormat.format(date)); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053124#comment-15053124 ] haiyang li edited comment on LANG-1077 at 12/11/15 6:23 PM: Sebb, It doesn't make sense. take a few minutes to think about the definition/contract of "indexOf", and consider "searchStr" as whole object, no matter it's "aa", or "ab". Or, try to think about the question: There is one string A: "aa", string B: "aa", how many B in A and return the index of each? was (Author: lihy70): Sebb, It doesn't make sense. take a few minutes to think about the definition/contract of "indexOf", and consider "searchStr" as whole object, no matter it's "aa", or "ab". > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Closed] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb closed LANG-1077. -- > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053159#comment-15053159 ] Sebb commented on LANG-1077: bq. There is one string A: "aa", string B: "aa", how many B in A and return the index of each? There are 5 B in A, indexes 0,1,2,3,4 Remember that overlapping matches are allowed, and indexes start at 0. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053183#comment-15053183 ] haiyang li commented on LANG-1077: -- There are ONLY 3 B in A. Consider the case: A: "ababab", B: "ab", or A:"aa", B: "aa". in different scenarios, the expected result should be same, not matter what in A and B. You are assuming the programmers always know what in B or have to check what in B, and remember what they should NOT when call this method. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053390#comment-15053390 ] Sebb commented on LANG-1077: The difference with "ab" is that it cannot ever match overlapping sections of the string. However consider A: "ababab" B: "aba". B matches at index 0, it also matches at index 2. Similarly for B: "abab" As I already wrote, the method allows overlapping matches. It did so until version 3.4 when the code was changed, breaking it in the process (e.g. JIRA-1193) I agree that the Javadoc was not precise, as it did not specify whether or not overlapping matches should be allowed. The Javadoc has now been clarified to agree with the original behaviour. It would of course be possible to have a different strategy whereby overlapping matches were not allowed, but that would be a change from the original behaviour, so would need a new method in order to avoid breaking the code for users that rely on the original behaviour. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053411#comment-15053411 ] haiyang li commented on LANG-1077: -- It's 19:18 at London? how are you doing today? It's Friday. Here is 11:18 at CA. JIRA-1193 is broken by wrong patch. the right code will work fine and fix JIRA-1193. You're keeping talking "overlapping matches". This is a general XXXIndexOf(...), not a match method... The doc looks good to me. what wrong is the behavior/code in the method. Even the java doc is updated with "overlapping matches is allowed". People may NOT notice it, or remember it, or even don't read the doc. It could bring bugs by unexpected result even doc is updated. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053437#comment-15053437 ] Thomas Neidhart commented on LANG-1077: --- This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: repeatedly execute indexOf with a start index of +1 compared to the last match. There are even suggestions on stackoverflow to use this method for exactly that use-case. What you are facing is a corner-case that was not described in the javadoc and thus it might create confusion for a user. So the right thing to do is what sebb did: revert the fix to the previous, working version and update the javadoc to document the corner case. Contrary to your opinion that this might introduce bugs, it is quite the opposite, your fix will introduce bugs as people relied on the previous version for a long time already. If there is a need for a method that does not handle overlaps, then this should be a new feature request. The method could have an additional flag to indicate how it handles overlaps. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053470#comment-15053470 ] Sebb commented on LANG-1077: I agree that had the patch been 'better' it would not have caused JIRA-1193 to be raised. In fact I was originally going to try to fix it accordingly. However, I looked further into it, and noticed that fixing the behaviour according to your original issue was not a good idea, as it would have changed the existing behaviour. The code was added to LANG in version 2.1 about 12 years ago, and the behaviour did not change until 3.4 which broke it. Although the behaviour is not what you expect, it is consistent with the original Javadoc. Furthermore the behaviour has been the same for multiple releases, so changing the behaviour now would potentially break existing applications. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053486#comment-15053486 ] haiyang li commented on LANG-1077: -- If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should returns 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053486#comment-15053486 ] haiyang li edited comment on LANG-1077 at 12/11/15 8:04 PM: If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. was (Author: lihy70): If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should returns 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053486#comment-15053486 ] haiyang li edited comment on LANG-1077 at 12/11/15 8:05 PM: If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't mean how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. was (Author: lihy70): If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053486#comment-15053486 ] haiyang li edited comment on LANG-1077 at 12/11/15 8:07 PM: If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't mean how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. By the way, again, JIRA-1193 in 3.4 was broken by the wrong patch/code, not by this ticket was (Author: lihy70): If as you said: "There are even suggestions on stackoverflow to use this method for exactly that use-case", (I think that use-case you referred is: StringUtils.ordinalIndexOf("aa", "aa", 2) should return 1), I agree to roll back the change to previous version. On the other side: "This code exists since a long time and looking at the implementation it is clear what it does and what its intention is: ..." How long it exists doesn't mean how right it is. Definitely it does incorrectly what it's supposed to do, from my aspect. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053494#comment-15053494 ] haiyang li commented on LANG-1077: -- OK, basically, I think all of us agree: "Furthermore the behaviour has been the same for multiple releases, so changing the behaviour now would potentially break existing applications.". The discussion can be moved to how to improve this method. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) != 3 in StringUtils
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053521#comment-15053521 ] haiyang li commented on LANG-1077: -- After think it about couple of minutes, I have another question: What're the general policies to fix bug/improve the code if it is not reported as bug in previous versions? Again, I can understand and agree to roll back the changes to previous version for this case since it has been there for a long time. > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils > -- > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (LANG-1077) [PATCH] StringUtils.ordinalIndexOf("aaaaaa", "aa", 2) should return 2
[ https://issues.apache.org/jira/browse/LANG-1077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] haiyang li updated LANG-1077: - Summary: [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2 (was: [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) != 3 in StringUtils) > [PATCH] StringUtils.ordinalIndexOf("aa", "aa", 2) should return 2 > - > > Key: LANG-1077 > URL: https://issues.apache.org/jira/browse/LANG-1077 > Project: Commons Lang > Issue Type: Bug > Components: lang.* >Affects Versions: 3.3.2 >Reporter: haiyang li > Labels: patch > Attachments: LANG-1077.patch > > > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > int found = 0; > int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > do { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index - > 1); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index + 1); > } > if (index < 0) { > return index; > } > found++; > } while (found < ordinal); > {code} > Should it be: > {code:title= org.apache.commons.lang3.StringUtils.java|borderStyle=solid} > private static int ordinalIndexOf(final CharSequence str, final > CharSequence searchStr, final int ordinal, final boolean lastIndex) { > //if (str == null || searchStr == null || ordinal <= 0) { > //return INDEX_NOT_FOUND; > //} > //if (searchStr.length() == 0) { > //return lastIndex ? str.length() : 0; > //} > //int found = 0; > //int index = lastIndex ? str.length() : INDEX_NOT_FOUND; > //do { > //if (lastIndex) { > //index = CharSequenceUtils.lastIndexOf(str, > searchStr, index - 1); > //} else { > //index = CharSequenceUtils.indexOf(str, searchStr, > index + 1); > //} > //if (index < 0) { > //return index; > //} > //found++; > //} while (found < ordinal); > //return index; > if (str == null || searchStr == null || ordinal <= 0) { > return INDEX_NOT_FOUND; > } > if (searchStr.length() == 0) { > return lastIndex ? str.length() : 0; > } > final int searchStrLen = searchStr.length(); > int index = lastIndex ? str.length() : 0; > for (int found = 0; index >= 0;) { > if (lastIndex) { > index = CharSequenceUtils.lastIndexOf(str, searchStr, index); > } else { > index = CharSequenceUtils.indexOf(str, searchStr, index); > } > if (index < 0) { > return INDEX_NOT_FOUND; > } > if (++found >= ordinal) { > break; > } > index = lastIndex ? index - searchStrLen : index + searchStrLen; > } > return index; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (VFS-512) LRUFilesCache grows arbitrarly
[ https://issues.apache.org/jira/browse/VFS-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053563#comment-15053563 ] Thomas Neidhart commented on VFS-512: - The LRUFilesCache does not release files that are attached. Now, basically any operation on a File object makes it attached, which is a pain. Changing your test code to this will prevent the cache from growing: {code} public static void visitDirs(FileObject dir) throws FileSystemException { // System.out.println(MemoryMeasurer.measureBytes(lruCache)); FileObject[] files = dir.getChildren(); dir.close(); count += files.length; for (FileObject f : files) { if (f.getType() == FileType.FOLDER) { try { visitDirs(f); } catch (FileSystemException e) { e.printStackTrace(); } } f.close(); } } {code} But I think the LRUFileCache should be change to allow also attached files to be removed from the cache. Maybe by first checking if there are any other files to be removed that are not attached. > LRUFilesCache grows arbitrarly > -- > > Key: VFS-512 > URL: https://issues.apache.org/jira/browse/VFS-512 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 >Reporter: Bela Hullar > Labels: leak > > We are experiencing memory issues in our system where we have to scan very > big directories. After doing some investigation it turned out that the cause > of the issue is the caching of vfs. > (http://mail-archives.apache.org/mod_mbox/commons-user/201312.mbox/browser) > From this reason we tried out LRUFilesCache, but it seems this cache can > still grow way beyond the limit. > This can be reproduced with a simple test code: > https://sourceforge.net/p/screeningbee/code/HEAD/tree/trunk/vfs-cache-test/src/main/java/ch/systemsx/bee/vfscachetest/CacheSizeChecker.java > In this example we set the max size of lru to 100, but running a while this > example and then checking the heap of the program showed that the real size > of the map can be 10 000 or more too. And it seems its growing constantly. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (VFS-569) DefaultFileMonitor recursive file
[ https://issues.apache.org/jira/browse/VFS-569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053611#comment-15053611 ] Thomas Neidhart commented on VFS-569: - Direct children of a directory are always added, regardless of the recursive flag, which seems to be intended behavior as it is also described like that in the code. So I would suggest to only update the documentation to clarify this. > DefaultFileMonitor recursive file > - > > Key: VFS-569 > URL: https://issues.apache.org/jira/browse/VFS-569 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: Java 7, windows 8, eclipse lune >Reporter: Sante > Attachments: VFS-569.patch > > > FileSystemManager fsManager = VFS.getManager(); > FileObject fileObj = > fsManager.resolveFile("file:///MyFolder"); > DefaultFileMonitor fm = new DefaultFileMonitor(listener); > fm.setDelay(1); > fm.setRecursive(false); > fm.addFile(fileObj); > fm.start(); > when execute fm.addFile(fileObj); library add listener an internal forder > although not recursive. > in this point: > if (file.getType().hasChildren()){ > // Traverse the children > final FileObject[] children = file.getChildren(); > for (final FileObject element : children) { > doAddFile(element); > } > } > variable children: should be a file and not a folder!!! -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (VFS-228) Ant regression with ClassNotFoundException for DefaultLocalFileProvider
[ https://issues.apache.org/jira/browse/VFS-228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053656#comment-15053656 ] Thomas Neidhart commented on VFS-228: - The provided testcase works for me when changing the task uri to org.apache.commons.vfs2.tasks. > Ant regression with ClassNotFoundException for DefaultLocalFileProvider > --- > > Key: VFS-228 > URL: https://issues.apache.org/jira/browse/VFS-228 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: java version "1.6.0_0" > IcedTea6 1.3.1 (6b12-0ubuntu6) Runtime Environment (build 1.6.0_0-b12) > OpenJDK Client VM (build 1.6.0_0-b12, mixed mode, sharing) > Apache Ant version 1.7.1 compiled on October 3 2008 >Reporter: Per Hermansson >Priority: Critical > Attachments: patch, test.xml, vfs-task.diff > > > The latest version from trunk fails to work with Apache Ant resulting in this > error: > Could not load VFS configuration from > "jar:file:/media/Fort/per/program/backup/lib/commons-vfs-2.0-SNAPSHOT.jar!/org/apache/commons/vfs/impl/providers.xml". > which was caused by > java.lang.ClassNotFoundException: > org.apache.commons.vfs.provider.local.DefaultLocalFileProvider > The cause seems to be a class loader issued introduced in rev 537717. > Reverting that change: > cd core > svn diff -c r537717 > src/main/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java | > patch -R > mvn clean install > [copy commons-vfs-2.0-SNAPSHOT to my test's lib dir] > ant -f test.xml test > Makes my example ant file work again (worked with the 1.0 release). > The 537717 revision was intended to fix > VFS-136: Don't force-set the classloader - Thanks to Adam Heath for the patch > So it might be a bit controversial to reverse that change. > Attaching patch fixing the issue and my example ant file. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (WEAVER-5) Incomplete sorting code causes infinite loop
Matt Benson created WEAVER-5: Summary: Incomplete sorting code causes infinite loop Key: WEAVER-5 URL: https://issues.apache.org/jira/browse/WEAVER-5 Project: Commons Weaver Issue Type: Bug Components: core Affects Versions: 1.1, 1.0 Reporter: Matt Benson Assignee: Matt Benson Priority: Critical Fix For: 1.2 The code that is responsible for sorting constructors and methods based on the number and types of their parameters is horribly broken. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (WEAVER-5) Incomplete sorting code causes infinite loop
[ https://issues.apache.org/jira/browse/WEAVER-5?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Benson resolved WEAVER-5. -- Resolution: Fixed r1719258 > Incomplete sorting code causes infinite loop > > > Key: WEAVER-5 > URL: https://issues.apache.org/jira/browse/WEAVER-5 > Project: Commons Weaver > Issue Type: Bug > Components: core >Affects Versions: 1.0, 1.1 >Reporter: Matt Benson >Assignee: Matt Benson >Priority: Critical > Fix For: 1.2 > > > The code that is responsible for sorting constructors and methods based on > the number and types of their parameters is horribly broken. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (WEAVER-6) Convert example modules into proper integration tests
Matt Benson created WEAVER-6: Summary: Convert example modules into proper integration tests Key: WEAVER-6 URL: https://issues.apache.org/jira/browse/WEAVER-6 Project: Commons Weaver Issue Type: Task Components: normalizer, privilizer Affects Versions: 1.1, 1.0 Reporter: Matt Benson Assignee: Matt Benson -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (WEAVER-6) Convert example modules into proper integration tests
[ https://issues.apache.org/jira/browse/WEAVER-6?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Benson resolved WEAVER-6. -- Resolution: Fixed revision 1719260 > Convert example modules into proper integration tests > - > > Key: WEAVER-6 > URL: https://issues.apache.org/jira/browse/WEAVER-6 > Project: Commons Weaver > Issue Type: Task > Components: normalizer, privilizer >Affects Versions: 1.0, 1.1 >Reporter: Matt Benson >Assignee: Matt Benson > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (VFS-393) The ls command allways returns the cached data
[ https://issues.apache.org/jira/browse/VFS-393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053682#comment-15053682 ] Thomas Neidhart commented on VFS-393: - This can indeed happen as the list of children are cached for a LocalFile implementation. A simple testcase illustrating the issue can be seen below: {code} // Locate file by absolute file name final String fileName = new File("testdir").getAbsolutePath(); final FileSystemManager mgr = VFS.getManager(); final FileObject dir = mgr.resolveFile(fileName); dir.createFolder(); FileObject child = dir.resolveFile("abc"); child.createFile(); System.out.println("first"); FileObject[] children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } new File("testdir/abc").delete(); //child.delete(); System.out.println("again"); children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } {code} in this case, the created file "testdir/abc" is deleted again via the standard java API, thus the VFS object does not get noticed about the change and returns the cached list of children. Now this can happen also when the file is removed from the filesystem by other means, so in this case you can do two things: * use a file monitor to listen for changes in the directory * release the cache resource of the file object before accessing the list of children via file.close() > The ls command allways returns the cached data > -- > > Key: VFS-393 > URL: https://issues.apache.org/jira/browse/VFS-393 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: Red hat Linux >Reporter: Prasad Kulkarni >Priority: Minor > Labels: patch > > We have follwed the below steps to reproduce the issue > 1. Created a folder under /home/xyz with name abc > 2. Tried to get the Childrens of /home/xyz > 3. I have got the folder listed as 'abc' although there are few other > childrens which are not considered and listed > 4. Deleted the folder 'abc' > 5. Tried to get the Childrens of /home/xyz > 6. It is still listing the folder 'abc' > We have also tried all three possible cache strategy but no luck. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (WEAVER-7) Support Weaver classloader in addition to context ClassLoader
Matt Benson created WEAVER-7: Summary: Support Weaver classloader in addition to context ClassLoader Key: WEAVER-7 URL: https://issues.apache.org/jira/browse/WEAVER-7 Project: Commons Weaver Issue Type: Improvement Components: core Affects Versions: 1.1, 1.0 Reporter: Matt Benson Assignee: Matt Benson Fix For: 1.2 The {{WeaveProcessor}} and {{CleanProcessor}} use the Java {{ServiceLoader}} to discover available {{Weaver}} and {{Cleaner}} SPI implementations, respectively. These should support the case in which the SPI impl is in the same CL as the interface it implements (the CW core in general) and not the TCCL. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (WEAVER-7) Support Weaver classloader in addition to context ClassLoader
[ https://issues.apache.org/jira/browse/WEAVER-7?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Benson resolved WEAVER-7. -- Resolution: Fixed r1719524 > Support Weaver classloader in addition to context ClassLoader > - > > Key: WEAVER-7 > URL: https://issues.apache.org/jira/browse/WEAVER-7 > Project: Commons Weaver > Issue Type: Improvement > Components: core >Affects Versions: 1.0, 1.1 >Reporter: Matt Benson >Assignee: Matt Benson > Fix For: 1.2 > > > The {{WeaveProcessor}} and {{CleanProcessor}} use the Java {{ServiceLoader}} > to discover available {{Weaver}} and {{Cleaner}} SPI implementations, > respectively. These should support the case in which the SPI impl is in the > same CL as the interface it implements (the CW core in general) and not the > TCCL. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (WEAVER-6) Convert example modules into proper integration tests
[ https://issues.apache.org/jira/browse/WEAVER-6?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Benson updated WEAVER-6: - Fix Version/s: 1.2 > Convert example modules into proper integration tests > - > > Key: WEAVER-6 > URL: https://issues.apache.org/jira/browse/WEAVER-6 > Project: Commons Weaver > Issue Type: Task > Components: normalizer, privilizer >Affects Versions: 1.0, 1.1 >Reporter: Matt Benson >Assignee: Matt Benson > Fix For: 1.2 > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (WEAVER-7) Support Weaver classloader in addition to context ClassLoader
[ https://issues.apache.org/jira/browse/WEAVER-7?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053723#comment-15053723 ] Matt Benson edited comment on WEAVER-7 at 12/11/15 10:52 PM: - revisions 1719524 and 1719586. was (Author: mbenson): r1719524 > Support Weaver classloader in addition to context ClassLoader > - > > Key: WEAVER-7 > URL: https://issues.apache.org/jira/browse/WEAVER-7 > Project: Commons Weaver > Issue Type: Improvement > Components: core >Affects Versions: 1.0, 1.1 >Reporter: Matt Benson >Assignee: Matt Benson > Fix For: 1.2 > > > The {{WeaveProcessor}} and {{CleanProcessor}} use the Java {{ServiceLoader}} > to discover available {{Weaver}} and {{Cleaner}} SPI implementations, > respectively. These should support the case in which the SPI impl is in the > same CL as the interface it implements (the CW core in general) and not the > TCCL. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Comment Edited] (VFS-393) The ls command allways returns the cached data
[ https://issues.apache.org/jira/browse/VFS-393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053682#comment-15053682 ] Thomas Neidhart edited comment on VFS-393 at 12/11/15 11:15 PM: This can indeed happen as the list of children are cached for a LocalFile implementation. A simple testcase illustrating the issue can be seen below: {code} // Locate file by absolute file name final String fileName = new File("testdir").getAbsolutePath(); final FileSystemManager mgr = VFS.getManager(); final FileObject dir = mgr.resolveFile(fileName); dir.createFolder(); FileObject child = dir.resolveFile("abc"); child.createFile(); System.out.println("first"); FileObject[] children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } new File("testdir/abc").delete(); //child.delete(); System.out.println("again"); children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } {code} in this case, the created file "testdir/abc" is deleted again via the standard java API, thus the VFS object does not get noticed about the change and returns the cached list of children. Now this can happen also when the file is removed from the filesystem by other means, so in this case you can do two things: * use a file monitor to listen for changes in the directory * call refresh() on the file object was (Author: tn): This can indeed happen as the list of children are cached for a LocalFile implementation. A simple testcase illustrating the issue can be seen below: {code} // Locate file by absolute file name final String fileName = new File("testdir").getAbsolutePath(); final FileSystemManager mgr = VFS.getManager(); final FileObject dir = mgr.resolveFile(fileName); dir.createFolder(); FileObject child = dir.resolveFile("abc"); child.createFile(); System.out.println("first"); FileObject[] children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } new File("testdir/abc").delete(); //child.delete(); System.out.println("again"); children = dir.getChildren(); for (FileObject c : children) { System.out.println(c.getName()); } {code} in this case, the created file "testdir/abc" is deleted again via the standard java API, thus the VFS object does not get noticed about the change and returns the cached list of children. Now this can happen also when the file is removed from the filesystem by other means, so in this case you can do two things: * use a file monitor to listen for changes in the directory * release the cache resource of the file object before accessing the list of children via file.close() > The ls command allways returns the cached data > -- > > Key: VFS-393 > URL: https://issues.apache.org/jira/browse/VFS-393 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: Red hat Linux >Reporter: Prasad Kulkarni >Priority: Minor > Labels: patch > > We have follwed the below steps to reproduce the issue > 1. Created a folder under /home/xyz with name abc > 2. Tried to get the Childrens of /home/xyz > 3. I have got the folder listed as 'abc' although there are few other > childrens which are not considered and listed > 4. Deleted the folder 'abc' > 5. Tried to get the Childrens of /home/xyz > 6. It is still listing the folder 'abc' > We have also tried all three possible cache strategy but no luck. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (VFS-143) Fix memory leak in DelegateFileObject in it's handling of listeners
[ https://issues.apache.org/jira/browse/VFS-143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Neidhart resolved VFS-143. - Resolution: Implemented Fix Version/s: 2.0 This has already been implemented in the 2.0 release. > Fix memory leak in DelegateFileObject in it's handling of listeners > --- > > Key: VFS-143 > URL: https://issues.apache.org/jira/browse/VFS-143 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 1.1 >Reporter: Adam Heath > Fix For: 2.0 > > Attachments: fix_DelegateFile-listener-leak.patch > > > DelegateFileObject adds itself as a listener to the wrapped file. This adds > a *hard* reference to the DelegateFileObject, which prevents it from being > garbaged collected. So, create a WeakRefFileListener proxy, to solve the > problem. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1192) FastDateFormat does not support the week-year component (uppercase 'Y')
[ https://issues.apache.org/jira/browse/LANG-1192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15054032#comment-15054032 ] Charles Honton commented on LANG-1192: -- 'u' is straight forward. implemented with commit 2ebf9a21d2dc99ab2f434111cac9dcd6da99d574 > FastDateFormat does not support the week-year component (uppercase 'Y') > --- > > Key: LANG-1192 > URL: https://issues.apache.org/jira/browse/LANG-1192 > Project: Commons Lang > Issue Type: Bug > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Dominik Stadler >Assignee: Charles Honton > > The Java SimpleDateFormat supports two year-components, 'y' for normal year > and 'Y' for 'Week year', see > http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html > However when we try to use FastDateFormat to parse a format which uses the > week-year, it fails with an exception > {noformat} > java.lang.IllegalArgumentException: Illegal pattern component: > at > org.apache.commons.lang3.time.FastDatePrinter.parsePattern(FastDatePrinter.java:282) > at > org.apache.commons.lang3.time.FastDatePrinter.init(FastDatePrinter.java:149) > at > org.apache.commons.lang3.time.FastDatePrinter.(FastDatePrinter.java:142) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:384) > at > org.apache.commons.lang3.time.FastDateFormat.(FastDateFormat.java:369) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:91) > at > org.apache.commons.lang3.time.FastDateFormat$1.createInstance(FastDateFormat.java:88) > at > org.apache.commons.lang3.time.FormatCache.getInstance(FormatCache.java:82) > at > org.apache.commons.lang3.time.FastDateFormat.getInstance(FastDateFormat.java:119) > {noformat} > Simple unit test to reproduce this: > {code} > @Test > public void testCommonsLang() { > Date date = new Date(); > Format dateFormat = new SimpleDateFormat(""); > assertNotNull(dateFormat.format(date)); > dateFormat = FastDateFormat.getInstance(""); > assertNotNull(dateFormat.format(date)); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)