cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Golod (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-6983) org.apache.cxf.jaxrs.provider.AbstractJAXBProvider#handleJAXBException doubles the error text for unmarshalling errors
Date Fri, 29 Jul 2016 08:23:20 GMT

     [ https://issues.apache.org/jira/browse/CXF-6983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mike Golod updated CXF-6983:
----------------------------
    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:
{code:title=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
        }
{code}

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

{quote}
JAXBExceptoin occured: <error text>. <error text>.
{quote}

  was:
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:
{code:title=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
        }
{code}

This code adds another message from linked exception. Message text is the same.



> org.apache.cxf.jaxrs.provider.AbstractJAXBProvider#handleJAXBException doubles the error
text for unmarshalling errors
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-6983
>                 URL: https://issues.apache.org/jira/browse/CXF-6983
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.1.6
>         Environment: CXF 3.1.6 with JAXB annotated beans
>            Reporter: Mike Golod
>            Priority: Trivial
>
> 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:
> {code:title=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
>         }
> {code}
> This code adds another message from linked exception. Message text is the same. Finally
we get something like:
> {quote}
> JAXBExceptoin occured: <error text>. <error text>.
> {quote}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message