You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/02/05 05:08:27 UTC

[jira] Resolved: (XERCESJ-1416) NPE creating (invalid) duration

     [ https://issues.apache.org/jira/browse/XERCESJ-1416?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1416.
-------------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.10.0

Thanks for reporting. I've added a null check and the factory now throws the correct exception.

> NPE creating (invalid) duration
> -------------------------------
>
>                 Key: XERCESJ-1416
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1416
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.datatype)
>    Affects Versions: 2.9.1
>         Environment: any
>            Reporter: Michele Vivoda
>            Assignee: Michael Glavassevich
>            Priority: Minor
>             Fix For: 2.10.0
>
>         Attachments: Test.java
>
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> creating a duration from "PT1D1H30M" (that is invalid since the 'T' should be after the 'D') causes a NullPointer in (DurationImpl.java:588), 
> invalid values passed to DatatypeFactory.newDuration(String) should cause an IllegalArgumentException
> Test case:
> javax.xml.datatype.DatatypeFactory.newInstance().newDuration("PT1D1H30M"); 
> or, to be sure, of getting the right factory 
> new org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl().newDuration("PT1D1H30M"); 
> the cause is in line 586:
> int nidx = tokens.lastIndexOf(parts[i].charAt(parts[i].length() - 1),   idx - 1);
> parts[i] is null in this case, so I propose the change:
> final String part = parts[i];
> if (part == null) throw new IllegalArgumentException(whole);
> int nidx = tokens.lastIndexOf(part.charAt(part.length() - 1),   idx - 1);
> I tried to check out the reason of the bug, it looks like the '1D' part is put in the day parts while parsing, but then I gave up, 
> I think this fix is safer because cannot influence other test cases.
> the bug affects also the internal Xerces of java5 and 6

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org