Repository: pinpoint-apm/pinpoint
Issue: Web throws NPE when filtering calls with RPC internal types
Labels: bug

When filtering RPC calls on Pinpoint web, NullPointerException is thrown.

This is due to a missing check inside the filtering logic. WAS -> WAS filtering checks each span event for its `ServiceType` and if it is in the RPC range (9000~9999), does an equals check with the span event's `destinationId`. Since RPC internal methods does not have a `destinationId`, while being within the RPC range, NPE is thrown.

Fix needs 2 checks - to check if the span event's ServiceType is set to record statistics, and to check for null `destinationId`.


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/web/src/main/java/com/navercorp/pinpoint/web/filter/FilterHint.java b/web/src/main/java/com/navercorp/pinpoint/web/filter/FilterHint.java
index 1da96e2f280f..c686337f2610 100644
--- a/web/src/main/java/com/navercorp/pinpoint/web/filter/FilterHint.java
+++ b/web/src/main/java/com/navercorp/pinpoint/web/filter/FilterHint.java
@@ -46,6 +46,10 @@ public boolean containApplicationEndpoint(String applicationName, String endPoin
         if (!containApplicationHint(applicationName)) {
             return false;
         }
+        
+        if (endPoint == null) {
+            return false;
+        }
 
         List<Object> list = get(applicationName);
 
diff --git a/web/src/main/java/com/navercorp/pinpoint/web/filter/FromToResponseFilter.java b/web/src/main/java/com/navercorp/pinpoint/web/filter/FromToResponseFilter.java
index a8fd905f9b4e..ff484bbef567 100644
--- a/web/src/main/java/com/navercorp/pinpoint/web/filter/FromToResponseFilter.java
+++ b/web/src/main/java/com/navercorp/pinpoint/web/filter/FromToResponseFilter.java
@@ -147,8 +147,10 @@ public boolean include(List<SpanBo> transaction) {
 
                     for (SpanEventBo event : eventBoList) {
                         // check only whether a client exists or not.
-                        if (event.getServiceType().isRpcClient() && toApplicationName.equals(event.getDestinationId())) {
-                            return checkResponseCondition(event.getEndElapsed(), event.hasException());
+                        if (event.getServiceType().isRpcClient() && event.getServiceType().isRecordStatistics()) {
+                            if (toApplicationName.equals(event.getDestinationId())) {
+                                return checkResponseCondition(event.getEndElapsed(), event.hasException());
+                            }
                         }
                     }
                 }
@@ -169,6 +171,10 @@ public boolean include(List<SpanBo> transaction) {
                         if (!event.getServiceType().isRpcClient()) {
                             continue;
                         }
+                        
+                        if (!event.getServiceType().isRecordStatistics()) {
+                            continue;
+                        }
 
                         if (!hint.containApplicationEndpoint(toApplicationName, event.getDestinationId(), event.getServiceType().getCode())) {
                             continue;


Test patch: