-
Bug
-
Resolution: Unresolved
-
P4
-
8, 21, 24, 25, 26
-
Fix Understood
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageTypes(-1) without input source returns an empty iterator instead of throwing an exception
IllegalStateException – if the input source has not been set.
IndexOutOfBoundsException – if the supplied index is out of bounds.
IOException – if an error occurs reading the format information from the input source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
catch Exception
ACTUAL -
class com.sun.imageio.plugins.jpeg.JPEGImageReader
false
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
public class JpegReaderTest {
public static void main(String[] args) {
Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("jpeg");
if (!readers.hasNext()) {
throw new RuntimeException("No jpeg image readers found");
}
ImageReader ir = readers.next();
System.out.println(ir.getClass());
try {
Iterator types = ir.getImageTypes(-1);
System.out.println(types.hasNext());
} catch (IOException | IndexOutOfBoundsException | IllegalStateException e) {
System.out.println(e.getMessage()); // expectied
}
}
}
---------- END SOURCE ----------
com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageTypes(-1) without input source returns an empty iterator instead of throwing an exception
IllegalStateException – if the input source has not been set.
IndexOutOfBoundsException – if the supplied index is out of bounds.
IOException – if an error occurs reading the format information from the input source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
catch Exception
ACTUAL -
class com.sun.imageio.plugins.jpeg.JPEGImageReader
false
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
public class JpegReaderTest {
public static void main(String[] args) {
Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("jpeg");
if (!readers.hasNext()) {
throw new RuntimeException("No jpeg image readers found");
}
ImageReader ir = readers.next();
System.out.println(ir.getClass());
try {
Iterator types = ir.getImageTypes(-1);
System.out.println(types.hasNext());
} catch (IOException | IndexOutOfBoundsException | IllegalStateException e) {
System.out.println(e.getMessage()); // expectied
}
}
}
---------- END SOURCE ----------
- links to
-
Review(master) openjdk/jdk/26522