From 110deefe1c223a1e3fa6feae08b6e558002eede5 Mon Sep 17 00:00:00 2001 From: BLasan Date: Fri, 16 Aug 2024 17:14:26 +0530 Subject: [PATCH] Fix: Analytics Type conversion issue --- .../handlers/common/APIMgtLatencyStatsHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/common/APIMgtLatencyStatsHandler.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/common/APIMgtLatencyStatsHandler.java index 2d14790fca61..4b06dc73f491 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/common/APIMgtLatencyStatsHandler.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/common/APIMgtLatencyStatsHandler.java @@ -109,11 +109,12 @@ public boolean handleResponse(MessageContext messageContext) { org.apache.axis2.context.MessageContext.setCurrentMessageContext(axis2MC); if (messageContext.getProperty(APIMgtGatewayConstants.BACKEND_REQUEST_END_TIME) == null) { messageContext.setProperty(APIMgtGatewayConstants.BACKEND_REQUEST_END_TIME, System.currentTimeMillis()); - if (APIUtil.isAnalyticsEnabled()) { - long executionStartTime = Long.parseLong((String) messageContext.getProperty(APIMgtGatewayConstants - .BACKEND_REQUEST_START_TIME)); - messageContext.setProperty(APIMgtGatewayConstants.BACKEND_LATENCY, System.currentTimeMillis() - - executionStartTime); + if (APIUtil.isAnalyticsEnabled() + && messageContext.getProperty(APIMgtGatewayConstants.BACKEND_REQUEST_START_TIME) != null) { + long executionStartTime = Long.parseLong( + (String) messageContext.getProperty(APIMgtGatewayConstants.BACKEND_REQUEST_START_TIME)); + messageContext.setProperty(APIMgtGatewayConstants.BACKEND_LATENCY, + System.currentTimeMillis() - executionStartTime); } } return true;