Author: elecharny
Date: Tue Oct 21 04:41:51 2008
New Revision: 706583
URL: http://svn.apache.org/viewvc?rev=706583&view=rev
Log:
Fixed the bug in slice(int, int).
Modified:
mina/trunk/core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
Modified:
mina/trunk/core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java?rev=706583&r1=706582&r2=706583&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
Tue Oct 21 04:41:51 2008
@@ -709,9 +709,14 @@
if (length < 0) {
throw new IllegalArgumentException("length: " + length);
}
- int pos = position();
+
int limit = limit();
- int endIndex = pos + length;
+
+ if (index > limit) {
+ throw new IllegalArgumentException("index: " + index);
+ }
+
+ int endIndex = index + length;
if (capacity() < endIndex) {
throw new IndexOutOfBoundsException("index + length (" + endIndex
@@ -723,7 +728,7 @@
limit(endIndex);
IoBuffer slice = slice();
- position(pos);
+ position(index);
limit(limit);
return slice;
}