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

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`.


Changed files:
web/src/main/java/com/navercorp/pinpoint/web/filter/FilterHint.java, web/src/main/java/com/navercorp/pinpoint/web/filter/FromToResponseFilter.java

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 1da96e2f28..c686337f26 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 class FilterHint extends HashMap<String, List<Object>> {
         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 a8fd905f9b..ff484bbef5 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 class FromToResponseFilter implements Filter {
 
                     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 class FromToResponseFilter implements Filter {
                         if (!event.getServiceType().isRpcClient()) {
                             continue;
                         }
+                        
+                        if (!event.getServiceType().isRecordStatistics()) {
+                            continue;
+                        }
 
                         if (!hint.containApplicationEndpoint(toApplicationName, event.getDestinationId(), event.getServiceType().getCode())) {
                             continue;