Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APIM 4.1.0] NPE in AnalyticsMetricsHandler When Axis2Sender.sendBack() Is Called Inside Custom Mediator in Request Flow with Analytics Enabled #3488

Closed
JanithaSampathBandara opened this issue Dec 30, 2024 · 1 comment

Comments

@JanithaSampathBandara
Copy link

Description

Following error is encountered when invoking APIs whereas a custom class mediator attached as a policy when analytics 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.295.jar:?]
	at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getBackendLatency(SynapseAnalyticsDataProvider.java:399) ~[org.wso2.carbon.apimgt.gateway_9.20.74.295.jar:?]
	at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getLatencies_aroundBody18(SynapseAnalyticsDataProvider.java:217) ~[org.wso2.carbon.apimgt.gateway_9.20.74.295.jar:?]
	at org.wso2.carbon.apimgt.gateway.handlers.analytics.SynapseAnalyticsDataProvider.getLatencies(SynapseAnalyticsDataProvider.java:215) ~[org.wso2.carbon.apimgt.gateway_9.20.74.295.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.295.jar:?]
	at org.wso2.carbon.apimgt.gateway.handlers.analytics.AnalyticsMetricsHandler.handleResponseOutFlow(AnalyticsMetricsHandler.java:81) ~[org.wso2.carbon.apimgt.gateway_9.20.74.295.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]
	at org.example.AuthFailure.mediate(AuthFailure.java:53) ~[AuthFailure-1.0-SNAPSHOT.jar:?]
	at org.apache.synapse.mediators.ext.ClassMediator.updateInstancePropertiesAndMediate(ClassMediator.java:182) ~[synapse-core_2.1.7.wso2v271_66.jar:2.1.7-wso2v271.66]
...

Steps to Reproduce

  1. Get an APIM 4.1.0 U2-177 pack and enable analytics [1].
  2. Implement and add the class mediator to the /lib folder.
  3. Create a sample API and add the implementation as a custom policy in the request flow of a resource.
  4. Invoke the API and the pointed error trace can be observed in the wso2carbon.log file.

Note : Noticed the same behaviour when adding a mediator as a custom policy.

[1] https://apim.docs.wso2.com/en/4.1.0/api-analytics/on-prem/elk-installation-guide/#step-1-configuring-api-manager

Version

4.1.0

Environment Details (with versions)

No response

@RakhithaRR
Copy link

Fixed with wso2/carbon-apimgt#12211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants