Author: bayard
Date: Tue Oct 31 15:00:54 2006
New Revision: 469696
URL: http://svn.apache.org/viewvc?view=rev&rev=469696
Log:
Fixng LANG-295 - thisBuf.length calls. There were two of the calls, so I've
committed a unit test showing things are broken and a fix in both cases.
Modified:
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrBuilderTest.java
Modified:
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java?view=diff&rev=469696&r1=469695&r2=469696
==============================================================================
---
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
(original)
+++
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
Tue Oct 31 15:00:54 2006
@@ -1670,7 +1670,7 @@
*/
public boolean contains(char ch) {
char[] thisBuf = buffer;
- for (int i = 0; i < thisBuf.length; i++) {
+ for (int i = 0; i < this.size; i++) {
if (thisBuf[i] == ch) {
return true;
}
@@ -1727,7 +1727,7 @@
return -1;
}
char[] thisBuf = buffer;
- for (int i = startIndex; i < thisBuf.length; i++) {
+ for (int i = startIndex; i < size; i++) {
if (thisBuf[i] == ch) {
return i;
}
Modified:
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrBuilderTest.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrBuilderTest.java?view=diff&rev=469696&r1=469695&r2=469696
==============================================================================
---
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrBuilderTest.java
(original)
+++
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrBuilderTest.java
Tue Oct 31 15:00:54 2006
@@ -1741,4 +1741,12 @@
assertEquals(-1, sb.indexOf("three"));
}
+ //-----------------------------------------------------------------------
+ public void testLang295() {
+ StrBuilder sb = new StrBuilder("onetwothree");
+ sb.deleteFirst("three");
+ assertFalse( "The contains(char) method is looking beyond the end of
the string", sb.contains('h'));
+ assertEquals( "The indexOf(char) method is looking beyond the end of
the string", -1, sb.indexOf('h'));
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]