Repository: wso2/product-microgateway
Issue: NPE when invoking Websocket APIs

### Description:
<!-- Describe the issue -->
$subject. Below log can be seen in the enforcer logs.
```
enforcer_1  | java.lang.NullPointerException
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.commons.model.RequestContext$Builder.populatePathParameters(RequestContext.java:454)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.commons.model.RequestContext$Builder.build(RequestContext.java:421)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.server.WebSocketHandler.buildRequestContext(WebSocketHandler.java:157)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.server.WebSocketHandler.process(WebSocketHandler.java:80)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.websocket.WebSocketResponseObserver.lambda$onNext$0(WebSocketResponseObserver.java:77)
enforcer_1  | 	at java.base/java.lang.Iterable.forEach(Unknown Source)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.websocket.WebSocketResponseObserver.onNext(WebSocketResponseObserver.java:70)
enforcer_1  | 	at org.wso2.choreo.connect.enforcer.websocket.WebSocketResponseObserver.onNext(WebSocketResponseObserver.java:41)
enforcer_1  | 	at io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener.onMessage(ServerCalls.java:249)
enforcer_1  | 	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailableInternal(ServerCallImpl.java:309)
enforcer_1  | 	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailable(ServerCallImpl.java:292)
enforcer_1  | 	at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1MessagesAvailable.runInContext(ServerImpl.java:782)
enforcer_1  | 	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
enforcer_1  | 	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
enforcer_1  | 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
enforcer_1  | 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
enforcer_1  | 	at java.base/java.lang.Thread.run(Unknown Source)
```
### Steps to reproduce:

### Affected Product Version:
<!-- Members can use Affected/*** labels -->
1.0.0-rc1-snapshot
### Environment details (with versions):
- OS:
- Client:
- Env (Docker/K8s):

Changed files:
enforcer-parent/commons/src/main/java/org/wso2/choreo/connect/enforcer/commons/model/RequestContext.java

diff --git a/enforcer-parent/commons/src/main/java/org/wso2/choreo/connect/enforcer/commons/model/RequestContext.java b/enforcer-parent/commons/src/main/java/org/wso2/choreo/connect/enforcer/commons/model/RequestContext.java
index 2a3eed21f..38f5b63e0 100644
--- a/enforcer-parent/commons/src/main/java/org/wso2/choreo/connect/enforcer/commons/model/RequestContext.java
+++ b/enforcer-parent/commons/src/main/java/org/wso2/choreo/connect/enforcer/commons/model/RequestContext.java
@@ -20,6 +20,8 @@ package org.wso2.choreo.connect.enforcer.commons.model;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -33,6 +35,7 @@ import java.util.TreeMap;
  * through out the complete request flow through the gateway enforcer.
  */
 public class RequestContext {
+    private static final Logger logger = LogManager.getLogger(RequestContext.class);
 
     //constants
     public static final String CLUSTER_HEADER = "x-wso2-cluster-header";
@@ -447,6 +450,11 @@ public class RequestContext {
          */
         private Map<String, String> populatePathParameters(String basePath, String resourceTemplate,
                                                            String rawPath) {
+            if (resourceTemplate == null || rawPath == null) {
+                logger.debug("Skip populating the path parameters. template: {}, rawPath: {}", resourceTemplate,
+                        rawPath);
+                return null;
+            }
             // Format the basePath and resourcePath to maintain consistency
             String formattedBasePath = basePath.startsWith("/") ? basePath : "/" + basePath;
             formattedBasePath = formattedBasePath.endsWith("/") ?
@@ -457,8 +465,7 @@ public class RequestContext {
             String formattedRawPath = rawPath.split("\\\\?")[0];
             final ParameterResolver parameterResolver = new ParameterResolver
                     (formattedBasePath + formattedResourcePathTemplate);
-            final Map<String, String> resultMap = parameterResolver.parametersByName(formattedRawPath);
-            return resultMap;
+            return parameterResolver.parametersByName(formattedRawPath);
         }
     }
 }