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

IIS.mark() / reset() does not work properly with PNG ImageReader

    Details

    • Subcomponent:
    • Introduced In Build:
      1.4
    • Introduced In Version:
    • Resolved In Build:
      b63
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      I am reading a PNG image using a PNG ImageReader. I am marking the initial position of the ImageInputStream through IIS.mark() call just before invoking the reader.read() method. This read process is aborted when it completes 50% by calling abort() in one of the listener methods. After this, I am resetting the position of the ImageInputStream to the initial marked position by calling IIS.reset(). Then I am using the same reader to the read the image till completion. This results in an IIOException. Call to IIS.reset() throws an exception saying the initially marked position has been discarded. Caching is disabled at begining of the application.

      PNG ImageReader actually calls IIS.flushBefore() which actually flushes the portion of the image input stream that was marked earlier. This does not seem to be happening with other image formats. However, there is an issue with JPEG where the abort flag is not cleared properly and causes every subsequent read operation to be aborted when abort() is called once. A separate bug has been filed on this. (4885702)

      This is reproducible on all platforms since JDK1.4.

      I have attached a sample testcase. Execute the testcase and pass a png image. You would see the exception given below when calling the reset() on the IIS.

      Here is the exception:
      javax.imageio.IIOException: Previous marked position has been discarded!
      at javax.imageio.stream.ImageInputStreamImpl.reset(ImageInputStreamImpl.java:780)
      at RasterListenerTest.<init>(RasterListenerTest.java:45)
      at RasterListenerTest.main(RasterListenerTest.java:67)

        Attachments

          Activity

            People

            • Assignee:
              campbell Christopher Campbell (Inactive)
              Reporter:
              pmohansunw Praveen Mohan (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: