Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8272998

ImageIO.read() throws incorrect exception type

    XMLWordPrintable

Details

    • b10
    • generic
    • generic

    Description

      The following test throws IllegalArgumentException in ImageIO.read(). According to spec only the following exceptions are expected:

       - IllegalArgumentException - if input is null.
       - IOException - if an error occurs during reading or when not able to create required ImageInputStream.

      There is a discrepancy between the Java specification and the implementation which needs to be resolved. According to the specification the expected outcome for this scenario would be an IOException.

      ../../../jdk/jdk-17.jdk/Contents/Home/bin/java Test
      Exception in thread "main" java.lang.IllegalArgumentException: Invalid scanline stride
      at java.desktop/java.awt.image.ComponentSampleModel.getBufferSize(ComponentSampleModel.java:265)
      at java.desktop/java.awt.image.ComponentSampleModel.verify(ComponentSampleModel.java:243)
      at java.desktop/java.awt.image.ComponentSampleModel.<init>(ComponentSampleModel.java:158)
      at java.desktop/java.awt.image.PixelInterleavedSampleModel.<init>(PixelInterleavedSampleModel.java:87)
      at java.desktop/java.awt.image.PixelInterleavedSampleModel.createCompatibleSampleModel(PixelInterleavedSampleModel.java:144)
      at java.desktop/javax.imageio.ImageTypeSpecifier.getSampleModel(ImageTypeSpecifier.java:1039)
      at java.desktop/javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1072)
      at java.desktop/javax.imageio.ImageReader.getDestination(ImageReader.java:2877)
      at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1159)
      at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1127)
      at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1470)
      at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1365)
      at Test.reproduceIssue(Test.java:46)
      at Test.<init>(Test.java:28)
      at Test.main(Test.java:78)

      Attachments

        Issue Links

          Activity

            People

              prr Philip Race
              mowerfel Marc Owerfeldt
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: