Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4462174

IIOMetadataNode.getAttribute: unspecified NullPointerException

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: dkR10031 Date: 05/23/2001


      Specification of the method
      javax.imageio.metadata.IIOMetadataNode.getAttribute says:

      "Returns:
               The Attr value as a string, or the empty string if that
               attribute does not have a specified or default value."

      and does not say anything about exceptions thrown.

      However, the implementation (JDK 1.4.0beta, build b65) of the method
      throws unspecified NullPointerException when the name of non-existent
      attribute is passed to the method.
      Also, it's not quite clear from the description what is a precise
      meaning of the words: "attribute does not have a specified or default
      value". I presumed this means an attribute is not set by the
      method setAttribute at least once. Is it correct? In any case, I think
      this phrase needs some clarification in the spec.

      This bug causes a failure of the new JCK test:
      api/javax_imageio/metadata/IIOMetadataNode/index.html#getAttribute

      To reproduce the bug run the following test:

      ------------ test09.java ------------------------
      import javax.imageio.metadata.IIOMetadataNode;

      public class test09 {

          public static void main(String argv[]) {

              String actValue;

              IIOMetadataNode parent = new IIOMetadataNode("parent");
          
              actValue = parent.getAttribute("attr");
              if (! actValue.equals("")) {
                  System.out.println("invalid value for not set attribute: " + actValue);
              } else {
                  System.out.println("Passed");
              }
          }
      }
      ------------ Logs -----------------------------
      $ java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      $ javac test09.java

      $ java test09
      Exception in thread "main" java.lang.NullPointerException
              at
      javax.imageio.metadata.IIOMetadataNode.getAttribute(IIOMetadataNode.java:659)
              at test09.main(test09.java:11)

      ======================================================================

            dricesunw Daniel Rice (Inactive)
            dimasunw Dima Dima (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: