JDK-4894894 : JPGMetadata.getAsTree() throws IllegalArgException for standard mdata format
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0,5.0,6,7,9,10,11,12,13,14
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2003-07-23
  • Updated: 2020-10-15
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
I am getting the default stream metadata from JPEGImageWriter using writer.getDefaultStreamMetadata(param). From this IIOMetadata object i retrieved the supported metadata format names by calling getMetadataFormatNames(). It returned 2 values which are given below.
javax_imageio_jpeg_stream_1.0 (Native)
javax_imageio_1.0 (Standard)

I tried to get the DOM tree for both the formats given above and I called IIOMetadata.getAsTree(formatName). The Stream Metadata obtained from JPEGWriter throws an IllegalArgumentException saying standard metadata format name given above is unsupported. If it is not supported, then it should not have been returned by getMetadataFormatNames(). I also checked the return value of isStandardMetadataFormatSupported() and it is returning true. Hence the behaviour of getAsTree() and other methods are contradicting with each other.

The documentation for getAsTree() claims that it will throw an IllegalArgException when the given format name is null or not one of the names returned by getMetadataFormatNames(). Both the conditions are not satisfied here and this method still throws IllegalArgException.

I looked into the source code of JPEGMetadata.getAsTree(). It basically checks whether the current object is a stream metadata object. if so, it throws this exception for all the formats that are not native ones. 

This is reproducible on all platforms right from JDK1.4+.
I have attached a sample code. Execute the sample code as follows.
java WriterStreamMetadataTest <format>
When you pass jpg as the format name, you will get the following exception:

java.lang.IllegalArgumentException: Unsupported format name: javax_imageio_1.0
 at com.sun.imageio.plugins.jpeg.JPEGMetadata.getAsTree(JPEGMetadata.java:751)
 at WriterStreamMetadataTest.<init>(WriterStreamMetadataTest.java:46)
 at WriterStreamMetadataTest.main(WriterStreamMetadataTest.java:98)

Comments
Test build: JDK11b23(CC-build(http://slc07hab.us.oracle.com/jdk_coverage/builds/11_23/jdk-11-instr_linux-x64_bin.tar.gz )) Platform :ubuntu18.04-x64 ute tool: tonga-4.0.2-rc2.jar Test case:2D_ImageIOTiger/WriterStreamMetadataTest The case failed as the same issue refer to the log: http://sc11152645.us.oracle.com:8080/evergreen/results/11/b23/2d-cc/auto/ubuntu18.04-x64/results-2d-run1/ResultDir/WriterStreamMetadataTest/WriterStreamMetadataTest.log
07-08-2018

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