wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
838 stars 783 forks source link

Run-time error occurred while mediating the message #4941

Closed Krishanx92 closed 5 years ago

Krishanx92 commented 5 years ago

Description:

API synapse xml Response caching enabled and chunking disabled as follows.

  <inSequence>
     <cache collector="false" timeout="501">
        <protocol type="HTTP">
           <methods>*</methods>
           <headersToExcludeInHash/>
           <responseCodes>.*</responseCodes>
           <enableCacheControl>false</enableCacheControl>
           <includeAgeHeader>false</includeAgeHeader>
           <hashGenerator>org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator</hashGenerator>
        </protocol>
        <implementation maxSize="500"/>
     </cache>

Wirelog:

TID: [-1] [] [2019-05-29 16:49:29,356] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "HTTP/1.1 200 [\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,356] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "Server: nginx/1.13.12[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,356] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "Date: Wed, 29 May 2019 14:49:29 GMT[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,356] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "Content-Length: 0[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,356] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "cpaas-transaction-id: test777108[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Sender I/O dispatcher-2 >> "[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << HTTP/1.1 200 {org.apache.synapse.transport.http.headers} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << Server: nginx/1.13.12 {org.apache.synapse.transport.http.headers} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << Date: Wed, 29 May 2019 14:49:29 GMT {org.apache.synapse.transport.http.headers} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << Content-Length: 0 {org.apache.synapse.transport.http.headers} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << Connection: keep-alive {org.apache.synapse.transport.http.headers} TID: [-1] [] [2019-05-29 16:49:29,357] DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-10473 << cpaas-transaction-id: test777108 {org.apache.synapse.transport.http.headers} TID: [1535030458] [] [2019-05-29 16:49:29,358] @cpaas.dcpp [1535030458] [AM]ERROR {org.apache.synapse.mediators.base.SequenceMediator} - Runtime error occurred while mediating the message {org.apache.synapse.mediators.base.SequenceMediator} java.lang.NullPointerException TID: [1535030458] [] [2019-05-29 16:49:29,358] @cpaas.dcpp [1535030458] [AM]ERROR {API_LOGGER.admindcpp-AT-cpaas.dcpp--DeviceCommand} - Runtime error occurred while mediating the message {API_LOGGER.admindcpp-AT-cpaas.dcpp--DeviceCommand} java.lang.NullPointerException TID: [1535030458] [] [2019-05-29 16:49:29,359] @cpaas.dcpp [1535030458] [AM] INFO {org.apache.synapse.mediators.builtin.LogMediator} - STATUS = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Runtime error occurred while mediating the message {org.apache.synapse.mediators.builtin.LogMediator}

We could observe that Client to Gateway request consists of the "Content-Length: 125 And Gateway to Backend Content-Length header has not sent. instead "Transfer-Encoding: chunked has sent

Backend to Gateway has responded with Content-Length: 0 with no content-type This has resulted in a NullPointerException in the gateway and has responded to client with a HTTP 500 error.

Krishanx92 commented 5 years ago

This issue occurs only if the back end is not supporting chunking hence resolve.