On 12/06/12 16:13, Simon Helsen wrote:
I agree it is not a release stopper
I actually don't think it is just the constants, although it clearly is
related to the yearMonthDuration. E.g. the following 2 variations on the
failing tests still fail with the same NPEs
@Test*public**void*nv_add_22() {
/testAdd/("'P1Y1M'^^xsd:yearMonthDuration",
"'PT4H'^^xsd:dayTimeDuration", "'P1Y1MT4H'^^xsd:duration") ; }
@Test*public**void*nv_sub_22() {
/testSub/("'P2Y3M'^^xsd:yearMonthDuration",
"'P1Y2M'^^xsd:yearMonthDuration", "'P1Y1M'^^xsd:yearMonthDuration") ; }
It seems that duration arithmetic which involves xsd:yearMonthDuration
is causing trouble unless it happens with a dateTime. E.g. the test
@Test*public**void*nv_add_24() {
/testAdd/("'2000-01-01T00:00:00Z'^^xsd:dateTime",
"'P1Y1M'^^xsd:yearMonthDuration",
"'2001-02-01T00:00:00Z'^^xsd:dateTime") ; }
seems to succeed.
I can look at filing a defect with the JRE folks, but if this is outside
XSD requirements for durations, I doubt they'll do anything about it. Is
there a reason Jena permits this behavior?
It's within the Java contract.
Note that the Java contract states that NPE is thrown iff the argument
is null. Otherwise the correct exception is IllegalStateException.
So NPE means NodevalueOps.additionNV
nv2.getDuration()
is null which track back to
"'PT4H'^^xsd:dayTimeDuration"
parses to a null duration on IBM and a Duration object on Sun.
That is from
Duration duration = xmlDatatypeFactory.newDuration(lex) ;
in NodeValue and hence DatatypeFactory.newInstance() is returning a
DatatypeFactory that can't parse PT4H as a dayTimeDuration. But then it
should throw IllegalArgumentException or UnsupportedOperationException.
Null is not a legal return value.
Given the way derived types work in XML,
Note the point of NPE is in xerces and the test set the Jena-shipped
version of Xerces so the versions of xerces are different and one has
been fixed if there is an endorsed jars. Otherwise, it is the inputs
being different hence DatatypeFactory or a under-java JVM bug, which is
unlikely.
Andy
Simon