harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey A. Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2777) [classlib][swing] j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw ArrayIndexOutOfBoundsException rather than NPE
Date Wed, 17 Jan 2007 07:41:28 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-2777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12465379
] 

Alexey A. Ivanov commented on HARMONY-2777:
-------------------------------------------

I've attached the patch to fix the failure of AbstractDocumentTest. Actually this test case
had the same assertions as those added to AbstractDocument_BranchElementTest.

Sorry for the inconveniences caused - I must have overlooked this.

> [classlib][swing] j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw
ArrayIndexOutOfBoundsException rather than NPE
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2777
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2777
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Alexey A. Ivanov
>         Assigned To: Mark Hindess
>            Priority: Minor
>         Attachments: H2777-AbstractDocument.patch, H2777-AbstractDocument_BranchElementTest.patch,
H2777-AbstractDocumentTest.patch
>
>
> The spec states that getEndOffset throws NPE if the element has no children [1].
> The spec doesn't say anything about exceptions for getStartOffset() [2]. However, it
also throws NPE in this case. The behavior of these methods should be similar in respect to
exceptions.
> [1] http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/AbstractDocument.BranchElement.html#getEndOffset()
> [2] http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/AbstractDocument.BranchElement.html#getStartOffset()
> ======= Code to Reproduce =======
> import javax.swing.text.PlainDocument;
> import javax.swing.text.AbstractDocument.BranchElement;
> public class Test {
>     public static void main(String[] args) {
>         PlainDocument doc = new PlainDocument();
>         BranchElement branch = doc.new BranchElement(null, null);
>         try {
>             System.err.println(branch.getStartOffset());
>         } catch (Exception e) {
>             System.err.println("getStartOffset:");
>             e.printStackTrace();
>         }
>         try {
>             System.err.println(branch.getEndOffset());
>         } catch (Exception e) {
>             System.err.println("getEndOffset:");
>             e.printStackTrace();
>         }
>     }
> }
> ======= end of code =======
> ------- Harmony Output -------
> getStartOffset:
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
> 	at javax.swing.text.AbstractDocument$BranchElement.getStartOffset(AbstractDocument.java:419)
> 	at Test.main(Test.java:9)
> getEndOffset:
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -1
> 	at javax.swing.text.AbstractDocument$BranchElement.getEndOffset(AbstractDocument.java:48)
> 	at Test.main(Test.java:15)
> ------- end of Harmony -------
> ------- RI Output -------
> getStartOffset:
> java.lang.NullPointerException
> 	at javax.swing.text.AbstractDocument$BranchElement.getStartOffset(AbstractDocument.java:2331)
> 	at Test.main(Test.java:9)
> getEndOffset:
> java.lang.NullPointerException
> 	at javax.swing.text.AbstractDocument$BranchElement.getEndOffset(AbstractDocument.java:2343)
> 	at Test.main(Test.java:15)
> ------- end of RI -------

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

        

Mime
View raw message