harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Loenko (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (HARMONY-1414) [classlib][html] javax.swing.text.html.parser.Element.getAttributeByValue(String) throws NullPointerException
Date Fri, 20 Oct 2006 04:20:38 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-1414?page=all ]

Mikhail Loenko reassigned HARMONY-1414:
---------------------------------------

    Assignee: Mikhail Loenko

> [classlib][html] javax.swing.text.html.parser.Element.getAttributeByValue(String) throws
NullPointerException
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1414
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1414
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Miguel Montes
>         Assigned To: Mikhail Loenko
>         Attachments: AttributeList_01.patch
>
>
> The method javax.swing.text.html.parser.Element.getAttributeByValue(String) throws NullPointerException
when at least one of its attributes, as represented with an instance of AttributeList, has
a null values field. The problem is in the method j.s.t.h.p.AttributeList.containsValue(String),
(with package visibility).
>   
>   //TODO correct a bit: Do we check an instance or just equals?
>     final boolean containsValue(final String value) {
>         if (value == this.value) {
>             return true;
>         }
>         return values.contains(value);
>     }
> This method doesn't check if values is null. In addition, it also compares its argument
with the field 'value', although the RI only searchs in 'values'. Besides that, it uses ==
instead of equals for checking string equality.
> ===========Java code for testing if value should be compared ==================
> import java.io.IOException;
> import java.util.Vector;
> import javax.swing.text.html.parser.*;
> public class TestAttributeList {
> 	public static void main(String[] args) throws IOException {
>         DTD dtd = DTD.getDTD("html");
>         Vector<String> vector = new Vector<String>();
>         vector.add("data");
>         vector.add("ref");
>         vector.add("object");
>         AttributeList attValueType = new AttributeList("valuetype", DTDConstants.NMTOKEN,
0, "DATA", vector, null);
>         Element param =dtd.defineElement("param", DTDConstants.EMPTY, false, true, null,
null, null, attValueType);
>         System.out.println(param.getAttributeByValue("DATA"));
> 	}
> }
> =============================================
> Output:
> $ java -showversion TestAttributeList
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
> null
> $ /harmony-hdk-r431938/jdk/jre/bin/java -showversion TestAttributeList
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r431938, (Aug 16 2006), Linux/ia32/gcc 3.4.6, release build
> http://incubator.apache.org/harmony
> AttributeList[name=valuetype, type=9, modifier=0, value=DATA, values=[data, ref, object],
next=null]
> ==========java code (NullPointerException)=======================
> import java.io.IOException;
> import java.util.Vector;
> import javax.swing.text.html.parser.*;
> public class TestAttributeList2 {
> 	public static void main(String[] args) throws IOException {
>         DTD dtd = DTD.getDTD("html");
>         Vector<String> vector = new Vector<String>();
>         vector.add("data");
>         vector.add("ref");
>        vector.add("object");
>         AttributeList attName = new AttributeList("type", DTDConstants.NAME, DTDConstants.REQUIRED,
null, null, null);
>         Element param =dtd.defineElement("param", DTDConstants.EMPTY, false, true, null,
null, null, attName);
>         System.out.println(param.getAttributeByValue("data"));
> 	}
> }
> =============================================================
> Output:
> $ java -showversion TestAttributeList2
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
> null
> $ /harmony-hdk-r431938/jdk/jre/bin/java -showversion TestAttributeList2
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r431938, (Aug 16 2006), Linux/ia32/gcc 3.4.6, release build
> http://incubator.apache.org/harmony
> java.lang.NullPointerException
>         at javax.swing.text.html.parser.AttributeList.containsValue(AttributeList.java:185)
>         at javax.swing.text.html.parser.Element.getAttributeByValue(Element.java:92)
>         at TestAttributeList2.main(TestAttributeList2.java:13)
> Attached is a patch for AttributeList

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message