JDK-4895547 : JPEGImageMetadata obtained from reader throws NPE when calling mergeTree()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-07-24
  • Updated: 2014-11-25
  • Resolved: 2004-09-07
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 6
6 mustangFixed
Related Reports
Relates :  
Description
I am getting the IIOMetadata object from the JPEG Reader by calling Reader.getImageMetadata(0). From this metadata object I am getting the Node object by calling IIOMetadata.getAsTree() and passing the native metadata format. I called IIOMetadata.mergeTree() and passed the native format name and the Node object obtained from the getAsTree() method. Typically I am merging the same tree with the same metadata object. In this case, mergeTree() is throwing a NPE (for JPEG) which is given below:

java.lang.NullPointerException
at com.sun.imageio.plugins.jpeg.MarkerSegment.getAttributeValue(MarkerSegment.java:131)
at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeDHTNode(JPEGMetadata.java:1254)
at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeSequenceSubtree(JPEGMetadata.java:1127)
at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeNativeTree(JPEGMetadata.java:1092)
at com.sun.imageio.plugins.jpeg.JPEGMetadata.mergeTree(JPEGMetadata.java:1064)
at ReaderImageMetadataTest.<init>(ReaderImageMetadataTest.java:59)
at ReaderImageMetadataTest.main(ReaderImageMetadataTest.java:115)

If mergeTree() does not support merging the same node obtained from getAsTree() it must throw a meaningful exception or IIOInvalidTreeException as specified by the specification. NullPointerExceptions leaves the user clueless on why it is being thrown.

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

I have attached a sample code. Execute the sample code as follows. 
java ReaderImageMetadataTest <img file>
You will get the above exception in the console.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang FIXED IN: mustang INTEGRATED IN: mustang
08-09-2004

EVALUATION Name: abR10136 Date: 04/19/2004 The problem here is quite trivial, it could be an mistype at line 1253: we get attribute list form parent node instead of child node. The list of parent attributes does not contain attributes related to the child node and this fact causes the NPE in the method MarkerSegment.getAttributeValue() when we try to get child related attribute. The solution is to get attribute list form child node. ======================================================================
08-09-2004