wso2 / api-manager

All issues, tasks, improvements and new features of WSO2 API Manager
Apache License 2.0
34 stars 8 forks source link

NPE in the AnalyticsMetricsHandler when invoking unavailable method #3377

Open Methma opened 3 days ago

Methma commented 3 days ago

Description

The following NPE is thrown when invoke an unavailable resource when Analytics is enabled.

ERROR - AnalyticsMetricsHandler Error Occurred when collecting data
java.lang.NullPointerException: null
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getBackendLatency_aroundBody54(SynapseAnalyticsDataProvider.java:404) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getBackendLatency(SynapseAnalyticsDataProvider.java:399) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getLatencies_aroundBody18(SynapseAnalyticsDataProvider.java:217) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getLatencies(SynapseAnalyticsDataProvider.java:215) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.wso2.carbon.apimgt.common.analytics.collectors.impl.SuccessRequestDataCollector.collectData(SuccessRequestDataCollector.java:71) ~[org.wso2.carbon.apimgt.common.analytics_9.20.74.289.jar:?]
    at org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector.collectData(GenericRequestDataCollector.java:46) ~[org.wso2.carbon.apimgt.common.analytics_9.20.74.289.jar:?]
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.AnalyticsMetricsHandler.handleResponseOutFlow_aroundBody8(AnalyticsMetricsHandler.java:95) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.wso2.carbon.apimgt.gateway.handlers.analytics.AnalyticsMetricsHandler.handleResponseOutFlow(AnalyticsMetricsHandler.java:81) ~[org.wso2.carbon.apimgt.gateway_9.20.74.300.jar:?]
    at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:188) ~[synapse-core_2.1.7.wso2v271_66.jar:2.1.7-wso2v271.66] 

To reproduce,

  1. Enable Analytics

    [apim.analytics]
    enable = true
    type = "elk"
  2. Create an API having few methods

  3. Invoke an unavailable method

Thanks Methma

Steps to Reproduce

Invoke an resource having mediations after enabling analytics.

Affected Component

APIM

Version

4.1.0

Environment Details (with versions)

No response

Relevant Log Output

No response

Related Issues

No response

Suggested Labels

No response