Details
-
Bug
-
Resolution: Fixed
-
P3
-
8, 11, 15, 16
-
b19
-
generic
-
generic
Description
ADDITIONAL SYSTEM INFORMATION :
Windows x64 19042.804 OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
WSL Kail Linux OpenJDK Runtime Environment (build 11.0.10+9-post-Debian-1)
A DESCRIPTION OF THE PROBLEM :
With some specific images, ImageIO.write() method will throw IndexOutOfBoundsException which isn't declared to be thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
My source code "MyChange.java" was pasted below.
And I uploaded the input image to https://i.ibb.co/Js518Zx/image.png.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
throw IOException or declare this method maybe throw IndexOutOfBoundsException
ACTUAL -
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.base/java.io.RandomAccessFile.writeBytes(Native Method)
at java.base/java.io.RandomAccessFile.write(RandomAccessFile.java:561)
at java.desktop/javax.imageio.stream.FileImageOutputStream.write(FileImageOutputStream.java:124)
at java.desktop/com.sun.imageio.plugins.bmp.BMPImageWriter.write(BMPImageWriter.java:654)
at java.desktop/javax.imageio.ImageWriter.write(ImageWriter.java:613)
at java.desktop/javax.imageio.ImageIO.doWrite(ImageIO.java:1628)
at java.desktop/javax.imageio.ImageIO.write(ImageIO.java:1554)
at test.MyChange.main(MyChange.java:16)
---------- BEGIN SOURCE ----------
package test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
public class MyChange {
public static void main(String[] args) {
File inputFile = new File("0.png");
try (InputStream is = new FileInputStream(inputFile)) {
BufferedImage image = ImageIO.read(is);
ImageIO.write(image, "bmp", new File("0.bmp"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows x64 19042.804 OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
WSL Kail Linux OpenJDK Runtime Environment (build 11.0.10+9-post-Debian-1)
A DESCRIPTION OF THE PROBLEM :
With some specific images, ImageIO.write() method will throw IndexOutOfBoundsException which isn't declared to be thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
My source code "MyChange.java" was pasted below.
And I uploaded the input image to https://i.ibb.co/Js518Zx/image.png.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
throw IOException or declare this method maybe throw IndexOutOfBoundsException
ACTUAL -
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.base/java.io.RandomAccessFile.writeBytes(Native Method)
at java.base/java.io.RandomAccessFile.write(RandomAccessFile.java:561)
at java.desktop/javax.imageio.stream.FileImageOutputStream.write(FileImageOutputStream.java:124)
at java.desktop/com.sun.imageio.plugins.bmp.BMPImageWriter.write(BMPImageWriter.java:654)
at java.desktop/javax.imageio.ImageWriter.write(ImageWriter.java:613)
at java.desktop/javax.imageio.ImageIO.doWrite(ImageIO.java:1628)
at java.desktop/javax.imageio.ImageIO.write(ImageIO.java:1554)
at test.MyChange.main(MyChange.java:16)
---------- BEGIN SOURCE ----------
package test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
public class MyChange {
public static void main(String[] args) {
File inputFile = new File("0.png");
try (InputStream is = new FileInputStream(inputFile)) {
BufferedImage image = ImageIO.read(is);
ImageIO.write(image, "bmp", new File("0.bmp"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Attachments
Issue Links
- clones
-
JDK-8262297 ImageIO.write() method will throw IndexOutOfBoundsException
-
- Resolved
-
- relates to
-
JDK-8278047 Few javax/imageio test regressed after JDK-8262297 fix
-
- Closed
-