-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
-
Not verified
Name: vpR10011 Date: 06/04/2001
Specification of the class javax.imageio.stream.ImageInputStreamImpl says:
"public void reset() throws IOException
Resets the current stream byte and bit positions from the stack of marked
positions.
Specified by:
reset in interface ImageInputStream
Following copied from interface: javax.imageio.stream.ImageInputStream
Throws:
IOException - if an I/O error occur."
This method throws unexpected IndexOutOfBoundsException when
the current stream byte position from the stack of marked positions
is smaller than the current flushed position.
To reproduce this bug run the following test:
---------------------test.java--------------
import java.io.*;
import javax.imageio.stream.*;
public class test {
public static void main(String[] argv) {
OutputStream os = (OutputStream) new ByteArrayOutputStream();
MemoryCacheImageOutputStream iosI =
new MemoryCacheImageOutputStream(os);
try {
iosI.writeBits(2L,7);
iosI.mark();
iosI.writeInt(1);
iosI.flush();
iosI.reset();
System.out.println("Passed");
} catch (Exception e) {
System.out.println("Failed: unxepected exception: " + e);
}
}
}
-----------------------------------------
% javac test.java
% java -version
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b66)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b66, mixed mode)
% java test
Failed: unxepected exception: java.lang.IndexOutOfBoundsException: pos < flushedPos!
----------------------------------------
======================================================================