[Bug](resource) fix npe on Resource read from json (#31723)
fix npe on Resource read from json
This commit is contained in:
@ -77,6 +77,10 @@ public class EsResource extends Resource {
|
||||
@SerializedName(value = "properties")
|
||||
private Map<String, String> properties;
|
||||
|
||||
public EsResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EsResource(String name) {
|
||||
super(name, Resource.ResourceType.ES);
|
||||
properties = Maps.newHashMap();
|
||||
|
||||
@ -44,6 +44,10 @@ public class HMSResource extends Resource {
|
||||
@SerializedName(value = "properties")
|
||||
private Map<String, String> properties;
|
||||
|
||||
public HMSResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HMSResource(String name) {
|
||||
super(name, ResourceType.HMS);
|
||||
this.properties = Maps.newHashMap();
|
||||
|
||||
@ -54,6 +54,10 @@ public class HdfsResource extends Resource {
|
||||
@SerializedName(value = "properties")
|
||||
private Map<String, String> properties;
|
||||
|
||||
public HdfsResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HdfsResource(String name) {
|
||||
super(name, Resource.ResourceType.HDFS);
|
||||
properties = Maps.newHashMap();
|
||||
|
||||
@ -65,7 +65,6 @@ public class OdbcCatalogResource extends Resource {
|
||||
@SerializedName(value = "configs")
|
||||
private Map<String, String> configs;
|
||||
|
||||
// only for deep copy
|
||||
public OdbcCatalogResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -111,6 +111,9 @@ public abstract class Resource implements Writable, GsonPostProcessable {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
// https://programmerr47.medium.com/gson-unsafe-problem-d1ff29d4696f
|
||||
// Resource subclass also MUST define default ctor, otherwise when reloading object from json
|
||||
// some not serialized field (i.e. `lock`) will be `null`.
|
||||
public Resource() {
|
||||
}
|
||||
|
||||
|
||||
@ -70,10 +70,9 @@ public class S3Resource extends Resource {
|
||||
@SerializedName(value = "properties")
|
||||
private Map<String, String> properties;
|
||||
|
||||
// for Gson fromJson
|
||||
// TODO(plat1ko): other Resource subclass also MUST define default ctor, otherwise when reloading object from json
|
||||
// some not serialized field (i.e. `lock`) will be `null`.
|
||||
public S3Resource() {}
|
||||
public S3Resource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public S3Resource(String name) {
|
||||
super(name, ResourceType.S3);
|
||||
|
||||
@ -117,6 +117,11 @@ public class SparkResource extends Resource {
|
||||
@SerializedName(value = "envConfigs")
|
||||
private Map<String, String> envConfigs;
|
||||
|
||||
|
||||
public SparkResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SparkResource(String name) {
|
||||
this(name, Maps.newHashMap(), null, null, Maps.newHashMap(), Maps.newHashMap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user