Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented exception thrown is incorrect for javax.xml.bind.DatatypeConverter#print(Object) methods #229

Closed
Tomas-Kraus opened this issue Apr 27, 2018 · 1 comment

Comments

@Tomas-Kraus
Copy link
Contributor

Previously tracked via: https://bugs.openjdk.java.net/browse/JDK-8152531

A DESCRIPTION OF THE PROBLEM :
The documentation for the javax.xml.bind.DatatypeConverter#print(Object) methods (such as printDate, printDateTime and printDecimal) state an IllegalArgumentException is thrown if the input parameter is null. In fact, a NullPointerException is thrown as shown in the Junit sample below:

@Test 
public void testJDate() { 

    this.exception.expect(IllegalArgumentException.class); 
    javax.xml.bind.DatatypeConverter.printDecimal(null); 

} 

java.lang.AssertionError:
Expected: an instance of java.lang.IllegalArgumentException
but: <java.lang.NullPointerException> is a java.lang.NullPointerException
Stacktrace was: java.lang.NullPointerException
at javax.xml.bind.DatatypeConverterImpl._printDecimal(DatatypeConverterImpl.java:546)
at javax.xml.bind.DatatypeConverterImpl.printDecimal(DatatypeConverterImpl.java:542)
at javax.xml.bind.DatatypeConverter.printDecimal(DatatypeConverter.java:514)
...

Of course, if it really SHOULD be an IllegalArgumentException, someone might want to open a jre bug report.

There is minimal impact as it is now unclear what should be thrown by a custom converter method.

URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/8/docs/api/javax/xml/bind/DatatypeConverter.html

@Tomas-Kraus
Copy link
Contributor Author

@lukasj lukasj transferred this issue from eclipse-ee4j/jaxb-ri May 17, 2022
antoniosanct added a commit to antoniosanct/jaxb-api that referenced this issue Dec 3, 2023
Signed-off-by: Antonio Santos Izaguirre <antoniosanct@gmail.com>
@lukasj lukasj closed this as completed in b950cd8 Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant