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

org.apache.cxf.jaxrs.provider.AbstractJAXBProvider#handleJAXBException doubles the error text for unmarshalling errors

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.1.6
    • Fix Version/s: 3.1.8, 3.2.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:

      CXF 3.1.6 with JAXB annotated beans

    • Estimated Complexity:
      Novice

      Description

      When unmarshal json payload to JAXB annotated bean sometimes we can get an UnmarshallingException (e.g. for dates). That exception already contains very descriptive message. AbstractJAXBProvider#handleExceptionStart extracts it. Then in AbstractJAXBProvider#handleJAXBException:

      AbstractJAXBProvider#handleJAXBException
      if (linked != null && linked.getMessage() != null) {
                  Throwable cause = linked;
                  while (read && cause != null) {
                      if (cause instanceof XMLStreamException && cause.getMessage().startsWith("Maximum Number")) {
                          throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); 
                      }
                      if (cause instanceof DepthExceededStaxException) {
                          throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); 
                      }
                      cause = cause.getCause();
                  }
                  sb.append(linked.getMessage()).append(". "); // this causes the problem
              }
      

      This code adds another message from linked exception. Message text is the same. Finally we get something like:

      JAXBException occured: <error text>. <error text>.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sergey_beryozkin Sergey Beryozkin
                Reporter:
                mage Mike Golod
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: