From bacebe8f5435f34683adf90aaad76b0aa55c568d Mon Sep 17 00:00:00 2001 From: Tharsanan1 Date: Mon, 7 Oct 2024 13:10:31 +0530 Subject: [PATCH] Fix nullpointer --- .../org/wso2/apk/enforcer/analytics/AnalyticsFilter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java index 85dc35773..d12c92fa1 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java @@ -210,11 +210,15 @@ public void handleSuccessRequest(RequestContext requestContext) { public String resolveEndpoint(RequestContext requestContext) { // For MockAPIs there is no backend, Hence "MockImplementation" is added as the destination. - if (requestContext.getMatchedAPI().isMockedApi()) { + if (requestContext.getMatchedAPI() != null && requestContext.getMatchedAPI().isMockedApi()) { return "MockImplementation"; } // This does not cause problems at the moment Since the current microgateway supports only one URL - return requestContext.getMatchedResourcePaths().get(0).getEndpoints().getUrls().get(0); + try { + return requestContext.getMatchedResourcePaths().get(0).getEndpoints().getUrls().get(0); + } catch (Exception e) { + return ""; + } } public void handleFailureRequest(RequestContext requestContext) {