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



##########
File path: 
oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/mx/ServiceMetaInfoAdapter.java
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.receiver.envoy.als.mx;
+
+import com.google.protobuf.Any;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.BytesValue;
+import com.google.protobuf.Struct;
+import java.nio.ByteBuffer;
+import java.util.Optional;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.receiver.envoy.als.ServiceMetaInfo;
+import Wasm.Common.FlatNode;
+import Wasm.Common.KeyVal;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Adapter to {@link ServiceMetaInfo} from various of other datastructures.
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceMetaInfoAdapter extends ServiceMetaInfo {
+
+    /**
+     * Try to adapt a {@link ByteString} to {@link ServiceMetaInfo} instance.
+     *
+     * @param bv the {@link ByteString byte string} to adapt from.
+     * @throws Exception if the {@link ByteString byte string} can not be 
adapted to a {@link ServiceMetaInfo}.
+     */
+    public ServiceMetaInfoAdapter(final ByteString bv) throws Exception {
+        final ByteBuffer buffer = 
ByteBuffer.wrap(BytesValue.parseFrom(bv).getValue().toByteArray());
+        final FlatNode flatNode = FlatNode.getRootAsFlatNode(buffer);
+        if (log.isDebugEnabled()) {
+            for (int i = 0; i < flatNode.labelsLength(); i++) {
+                KeyVal kv = flatNode.labels(i);
+                log.debug("wasm label: {} : {}", kv.key(), kv.value());

Review comment:
       *NULL_DEREFERENCE:*  object `kv` last assigned on line 53 could be null 
and is dereferenced at line 54.




----------------------------------------------------------------
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:
[email protected]


Reply via email to