Why is Sonar flagging up this as a possible NullPointerException?

```
public void credentialSetter(@Headers Map<String, Object> headersMap) {

    SoapHeader uName = new SoapHeader(new QName(NAMESPACE_URL, USERNAMETOKEN), 
            setCredentials(USERNAMETOKEN, this.username).getDocumentElement());

    SoapHeader pTxt = new SoapHeader(new QName(NAMESPACE_URL, P), 
            setCredentials(P, this.pas).getDocumentElement());

```

It flats up at "setCredentials" both times, I've tried surrounding it with an if statement to check if it's not null, also tried to check if it's null in the actual method just to cover all basis. 

```
private Document setCredentials(String credential, String value) {
    StringWriter writer = new StringWriter();
    JAXBContext context;
    try {
        if (null != credential && null != value) {
            context = JAXBContext.newInstance(value.getClass());
            QName qName = new QName(NAMESPACE_URL, credential);
            JAXBElement<String> root = new JAXBElement<>(qName, String.class, value);
            context.createMarshaller().marshal(root, writer);
            return DocumentBuilderFactory.newInstance().newDocumentBuilder()
                    .parse(new InputSource(new StringReader(writer.toString())));
        }
    } catch (Exception e) {
        LOG.error("Error converting {} to XML {}", credential, e);
    }
    return null;
}

```