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

Javadoc on many methods mention null is never returned, where null can actually be returned #365

Ricq opened this Issue May 17, 2016 · 1 comment


None yet
2 participants

Ricq commented May 17, 2016

Many accessor methods in the HAPI FHIR API have Javadoc that mentions that the methods cannot return null, while the methods can actually return null. This is pretty confusing and can easily lead to NullPointerException bugs.

As an example, see the CodingDt.getCode() method:

 * Gets the value(s) for <b>code</b> ().
 * creating it if it does
 * not exist. Will not return <code>null</code>.
 * <p>
 * <b>Definition:</b>
 * A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)
 * </p> 
public String getCode() {  
    return getCodeElement().getValue();

getCodeElement() is designed to not return null. It will create a new CodeDt instance if it was null. The getValue() call on that just-created code however, will actually return null.

I'm OK with the methods returning null, but the Javadoc should be cleaned up. It exists on many, if not all accessor methods on the datatypes.


This comment has been minimized.


jamesagnew commented Jun 8, 2016

Thanks for reporting! This looks like it was a copy-and-paste error, and I'd agree it is confusing! Checking in a fix now.

@jamesagnew jamesagnew closed this in 4a73282 Jun 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment