Fix NPE in protobuf and illegal query parameter. (#1847)
This commit is contained in:
parent
041ed43309
commit
dbf0444ec1
|
|
@ -31,6 +31,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnIds;
|
|||
import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.module.Service;
|
||||
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
|
|
@ -56,6 +57,10 @@ public class MetricQueryService implements Service {
|
|||
|
||||
public IntValues getValues(final String indName, final List<String> ids, final Step step, final long startTB,
|
||||
final long endTB) throws IOException {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new RuntimeException("IDs can't be null");
|
||||
}
|
||||
|
||||
Where where = new Where();
|
||||
KeyValues intKeyValues = new KeyValues();
|
||||
intKeyValues.setKey(Indicator.ENTITY_ID);
|
||||
|
|
|
|||
|
|
@ -18,15 +18,19 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.register;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.register.annotation.InventoryType;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntity;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -87,7 +91,7 @@ public class EndpointInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(name);
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
|||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -87,7 +88,7 @@ public class NetworkAddressInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(name);
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.apache.skywalking.oap.server.core.source.Scope;
|
|||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -122,11 +123,11 @@ public class ServiceInstanceInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(name);
|
||||
remoteBuilder.addDataStrings(osName);
|
||||
remoteBuilder.addDataStrings(hostName);
|
||||
remoteBuilder.addDataStrings(ipv4s);
|
||||
remoteBuilder.addDataStrings(instanceUUID);
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(osName, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(hostName, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(ipv4s, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(instanceUUID, Const.EMPTY_STRING));
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.apache.skywalking.oap.server.core.source.Scope;
|
|||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -105,7 +106,7 @@ public class ServiceInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
remoteBuilder.addDataLongs(getMappingLastUpdateTime());
|
||||
|
||||
remoteBuilder.addDataStrings(name);
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,4 +32,8 @@ public class StringUtils {
|
|||
public static boolean isNotEmpty(Object str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
public static String getOrDefault(String value, String defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue