Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4895547
Votes 0
Synopsis JPEGImageMetadata obtained from reader throws NPE when calling mergeTree()
Category java:imageio
Reported Against 1.4
Release Fixed mustang
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs 5094154
Submit Date 24-JUL-2003
Description
I am getting the IIOMetadata  customer  from the JPEG Reader by calling Reader.getImageMetadata(0). From this metadata  customer  I am getting the Node  customer  by calling IIOMetadata.getAsTree() and passing the native metadata format. I called IIOMetadata.mergeTree() and passed the native format name and the Node  customer  obtained from the getAsTree() method. Typically I am merging the same tree with the same metadata  customer . 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.
Work Around
N/A
Evaluation





 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.

======================================================================
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang