United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4895547 JPEGImageMetadata obtained from reader throws NPE when calling mergeTree()
JDK-4895547 : JPEGImageMetadata obtained from reader throws NPE when calling mergeTree()

Details
Type:
Bug
Submit Date:
2003-07-24
Status:
Closed
Updated Date:
2009-09-28
Project Name:
JDK
Resolved Date:
2004-09-07
Component:
client-libs
OS:
generic
Sub-Component:
javax.imageio
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0,6
Fixed Versions:

Related Reports
Relates:

Sub Tasks

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
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.

======================================================================
                                     
2004-09-08
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang

FIXED IN:
mustang

INTEGRATED IN:
mustang


                                     
2004-09-08



Hardware and Software, Engineered to Work Together