Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4684

SOAPFault message improvement in CXF when there is unchecked NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.2
    • 2.5.8, 2.6.5, 2.7.2
    • WS-* Components
    • None
    • Unknown

    Description

      When there is unchecked NPE thrown, the SOAPFault in CXF will only throw the "Fault occurred while processing." message rather than the original NPE message.

      Analysis:
      1. In org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor and org.apache.cxf.binding.soap.interceptor.Soap12FaultOutInterceptor,
      It will check fault.getMessage() :
      if (fault.getMessage() != null) {
      if (message.get("forced.faultstring") != null)

      { writer.writeCharacters((String) message.get("forced.faultstring")); }

      else

      { writer.writeCharacters(fault.getMessage()); }

      } else

      { writer.writeCharacters("Fault occurred while processing."); }

      But for NPE, the fault.getMessage() will return null instead of the "java.lang.NullPointerException" in the getMessage() in NPE.

      2.
      Fault.getMessage will return null in the NPE scenario while it's super class Throwable will not.
      When there is NPE, the message attribute in Fault is null while the detailMessageAtrribute is "java.lang.NullPointerException".
      Details:
      SoapFault->Fault->UncheckedException->RuntimeException->Exception->Throwable. // SoapFault->Fault means SoapFault class extends Fault class
      UncheckedException.getMessage:
      public String getMessage() {
      if (null != message)

      { return message.toString(); }

      return null;
      }
      Throwable.getMessage:
      public String getMessage() {
      return detailMessage;
      }

      Attachments

        1. CXF-4684.patch
          0.4 kB
          Bin Zhu

        Activity

          People

            ay Akitoshi Yoshida
            zhubinbj Bin Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: