title: A "NullPointerException" could be thrown; "setCredentials()" can return null
body: <p>Why is Sonar flagging up this as a possible NullPointerException?</p>
  
  <pre><code>public void credentialSetter(@Headers Map&lt;String, Object&gt; 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());
  </code></pre>
  
  <p>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. </p>
  
  <pre><code>private Document setCredentials(String credential, String value) {
      StringWriter writer = new StringWriter();
      JAXBContext context;
      try {
          if (null != credential &amp;&amp; null != value) {
              context = JAXBContext.newInstance(value.getClass());
              QName qName = new QName(NAMESPACE_URL, credential);
              JAXBElement&lt;String&gt; root = new JAXBElement&lt;&gt;(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;
  }
  </code></pre>