JDK-4958064 : JPGWriter does not throw UnsupportedException when canWriteSequence retuns false
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-11-21
  • Updated: 2015-09-29
  • Resolved: 2015-02-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b56Fixed
Description
The API Doc for ImageWriter.PrepareWriteSequence() claims that this method will throw UnsupportedOperationException when canWriteSequence() returns false. But this does not seem to be happening for JPEG ImageWriter. JPG writer has failed to override the method canWriteSequence() and relies on the parent class ImageWriter which returns a 'false' value by default. But JPEGImageWriter class has actually implemented the method prepareWriteSequence() and it does not throw UnsupportedOperationException when canWriteSequence() returns false. I feel JPEGImageWriter class must override the method canWriteSequence() and must return a 'true' value since it actually supports the prepareWriteSequence and endWriteSequence() methods. Otherwise it must throw the expected exception - UnsupportedOperationException. This works fine for all other writers.

This is reproducible on all platforms right from JDK1.4.

I have attached a sample testcase. Execute the testcase with 'JPG' commandline argument and watch the console for the status messages. If you see a 'FAIL' message the bug is reproduced.

Comments
Please re-open if - if fix is in progress or on the plan to fix soon - if this is a P3 (file as P3, not P4)
14-03-2014

EVALUATION Will fix as described since we do support appending image to the image stream for jpeg images.
20-07-2007