You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/02/05 05:06:09 UTC

[GitHub] [skywalking] muse-dev[bot] commented on a change in pull request #6327: Add some defensive codes for NPE and bump up Kubernetes client version to expose exception stack trace

muse-dev[bot] commented on a change in pull request #6327:
URL: https://github.com/apache/skywalking/pull/6327#discussion_r570723066



##########
File path: oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/k8s/K8SServiceRegistry.java
##########
@@ -201,52 +200,58 @@ public void onDelete(final V1Pod pod, final boolean deletedFinalStateUnknown) {
     }
 
     protected void addService(final V1Service service) {
-        Optional.ofNullable(service.getMetadata()).ifPresent(
+        ofNullable(service.getMetadata()).ifPresent(
             metadata -> idServiceMap.put(metadata.getNamespace() + ":" + metadata.getName(), service)
         );
 
         recompose();
     }
 
     protected void removeService(final V1Service service) {
-        Optional.ofNullable(service.getMetadata()).ifPresent(
+        ofNullable(service.getMetadata()).ifPresent(
             metadata -> idServiceMap.remove(metadata.getUid())
         );
     }
 
     protected void addPod(final V1Pod pod) {
-        Optional.ofNullable(pod.getStatus()).ifPresent(
+        ofNullable(pod.getStatus()).ifPresent(
             status -> ipPodMap.put(status.getPodIP(), pod)
         );
 
         recompose();
     }
 
     protected void removePod(final V1Pod pod) {
-        Optional.ofNullable(pod.getStatus()).ifPresent(
+        ofNullable(pod.getStatus()).ifPresent(
             status -> ipPodMap.remove(status.getPodIP())
         );
     }
 
     protected void addEndpoints(final V1Endpoints endpoints) {
-        final String namespace = requireNonNull(endpoints.getMetadata()).getNamespace();
-        final String name = requireNonNull(endpoints.getMetadata()).getName();
+        V1ObjectMeta endpointsMetadata = endpoints.getMetadata();
+        if (isNull(endpointsMetadata)) {
+            log.error("Endpoints metadata is null: {}", endpoints);
+            return;
+        }
+
+        final String namespace = endpointsMetadata.getNamespace();

Review comment:
       *NULL_DEREFERENCE:*  object `endpointsMetadata` last assigned on line 231 could be null and is dereferenced at line 237.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org