Skip to content

Commit

Permalink
Added null check.
Browse files Browse the repository at this point in the history
  • Loading branch information
prasa7 committed Jun 23, 2023
1 parent cee771a commit 90f3c37
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,20 @@ protected static String getMatchingLogLevel(MessageContext ctx, Map<String, Stri

String path = ApiUtils.getFullRequestPath(ctx);
String tenantDomain = GatewayUtils.getTenantDomain();
TreeMap selectedAPIS = Utils.getSelectedAPIList(path, tenantDomain);
String selectedPath = (String) selectedAPIS.firstKey();
API api = (API) selectedAPIS.get(selectedPath);
String apiCtx = api.getContext();
for (Map.Entry<String, String> entry : logProperties.entrySet()) {
String key = entry.getKey().substring(1);
if (apiCtx.startsWith("/" + key) || apiCtx.equals(key)) {
ctx.setProperty(LogsHandler.LOG_LEVEL, entry.getValue());
ctx.setProperty("API_TO", apiCtx);
return entry.getValue();
TreeMap<String, API> selectedAPIS = Utils.getSelectedAPIList(path, tenantDomain);
if (selectedAPIS.size() > 0) {
String selectedPath = (String) selectedAPIS.firstKey();
API searchedAPI = (API) selectedAPIS.get(selectedPath);
if (searchedAPI != null) {
String apiCtx = searchedAPI.getContext();
for (Map.Entry<String, String> entry : logProperties.entrySet()) {
String key = entry.getKey().substring(1);
if (apiCtx.startsWith("/" + key) || apiCtx.equals(key)) {
ctx.setProperty(LogsHandler.LOG_LEVEL, entry.getValue());
ctx.setProperty("API_TO", apiCtx);
return entry.getValue();

Check warning on line 141 in components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/LogUtils.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/LogUtils.java#L139-L141

Added lines #L139 - L141 were not covered by tests
}
}
}
}
return null;
Expand Down

0 comments on commit 90f3c37

Please sign in to comment.