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

removeAttributeNode fails to throw DOMException

XMLWordPrintable

    • beta2
    • generic
    • generic

      c

      Name: dkR10031 Date: 05/25/2001


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

      "Throws:
          DOMException - ...
          NOT_FOUND_ERR: Raised if oldAttr is not an attribute of the element."

      However, the implementation (JDK 1.4.0beta, build b65) of the method
      does not throw DOMException when given attribute node is not
      an attribute of the IIOMetadataNode.

      This bug affects new JCK test:
      api/javax_imageio/metadata/IIOMetadataNode/index.html#removeAttributeNode

      To reproduce the bug run the following test:

      ------------ test10.java ------------------------
      import javax.imageio.metadata.IIOMetadataNode;
      import org.w3c.dom.Attr;
      import org.w3c.dom.Element;

      class test10 {

          public static void main(String argv[]) {

              IIOMetadataNode parent = new IIOMetadataNode("parent");
              MyAttrNode attrNode = new MyAttrNode("attr", "2001");

              try {
                  parent.removeAttributeNode(attrNode);
              } catch(org.w3c.dom.DOMException e) {
                  if (e.code != org.w3c.dom.DOMException.NOT_FOUND_ERR) {
                      System.out.println("Failed: invalid exception code: " + e.code);
                  } else {
                      System.out.println("Passed");
                  }
                  return;
              }
              System.out.println("Failed: failed to throw DOMException");
          }
      }

      class MyAttrNode extends IIOMetadataNode implements Attr {
          public Element owner;
          private String name;
          private String value;


          public MyAttrNode(String name, String value) {
              this.name = name;
              this.value = value;
          }
          public String getName() {
              return name;
          }
          public Element getOwnerElement() {
              return owner;
          }
          public boolean getSpecified() {
              return false;
          }
          public String getValue() {
              return value;
          }
          public void setValue(String value) {
              this.value = value;
          }
      }
      ------------ 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 test10.java

      $ java test10
      Failed: failed to throw DOMException

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

            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: