ImageIO.read() can't read some images
<p>I have a GIF image and try to read it into BufferedImage.</p>

<pre><code>public class ImageReadTest {

    public static void main(String[] args) throws IOException {
        f(new File("/Users/hieugioi/Downloads/Photos/butterfly.gif"));
    }

    public static void f(File file) throws IOException {
        BufferedImage image = ImageIO.read(file);
    }

}
</code></pre>

<p>It shows errors: </p>

<pre><code>Exception in thread "main" java.lang.IndexOutOfBoundsException
    at java.io.RandomAccessFile.readBytes(Native Method)
    at java.io.RandomAccessFile.read(RandomAccessFile.java:377)
    at javax.imageio.stream.FileImageInputStream.read(FileImageInputStream.java:117)
    at com.sun.imageio.plugins.gif.GIFImageReader.getCode(GIFImageReader.java:351)
    at com.sun.imageio.plugins.gif.GIFImageReader.read(GIFImageReader.java:950)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1308)
    at com.hieutest.ImageReadTest.f(ImageReadTest.java:16)
    at com.hieutest.ImageReadTest.main(ImageReadTest.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
</code></pre>

<p>The "butterfly" image got from <a href="https://code.google.com/archive/p/imagetestsuite/downloads" rel="nofollow noreferrer">this open source project</a>:</p>

<p><a href="https://i.stack.imgur.com/9fl9J.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9fl9J.gif" alt="enter image description here"></a></p>

<p>It succeeds with other regular images but it fails with this image. Is it image problem or API bug?</p>