Skip to content

Commit 93e18a3

Browse files
committed
gen entities should initialize list,set,map by default && timeout handling && thrift removing
1 parent 25a9d9d commit 93e18a3

File tree

60 files changed

+106
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+106
-317
lines changed

build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
buildscript {
22
dependencies {
3-
classpath "gradle.plugin.org.jruyi.gradle:thrift-gradle-plugin:0.4.1"
43
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.11'
54
}
65
}
@@ -34,7 +33,6 @@ repositories {
3433
apply plugin: 'com.google.protobuf'
3534
apply plugin: 'idea' // IntelliJ plugin to see files generated from protos
3635
apply plugin: 'maven'
37-
apply plugin: 'org.jruyi.thrift'
3836
apply plugin: 'maven-publish'
3937
apply plugin: 'com.github.sherter.google-java-format'
4038

@@ -77,7 +75,6 @@ dependencies {
7775

7876
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.30'
7977
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
80-
compile group: 'org.apache.thrift', name: 'libthrift', version: '0.9.3'
8178
compile group: 'com.google.code.gson', name: 'gson', version: '2.10'
8279
compile group: 'com.uber.m3', name: 'tally-core', version: '0.11.1'
8380
compile group: 'com.google.guava', name: 'guava', version: '31.1-jre'

scripts/v4_entity_generator/generator.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
type Field struct {
2020
Name string
2121
Type string
22+
Initializer string
2223
}
2324

2425
type TemplateEntity struct {
@@ -119,9 +120,22 @@ func (g *Generator) generateStruct(v *ast.Struct, outputDir string, packageName
119120
return fmt.Errorf("failed to map field type: %w", err)
120121
}
121122

123+
initializer := ""
124+
switch field.Type.(type) {
125+
case ast.SetType:
126+
initializer = " = new HashSet<>();"
127+
case ast.ListType:
128+
initializer = " = new ArrayList<>();"
129+
case ast.MapType:
130+
initializer = " = new HashMap<>();"
131+
}
132+
133+
fmt.Println(field.Name, initializer, typeStr)
134+
122135
fields = append(fields, Field{
123136
Name: field.Name,
124137
Type: typeStr,
138+
Initializer: initializer,
125139
})
126140
}
127141

scripts/v4_entity_generator/template/java_struct.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import {{.}};
1111
@Accessors(chain = true)
1212
public class {{.ClassName}} {
1313
{{- range .Fields}}
14-
private {{.Type}} {{.Name}};
14+
private {{.Type}} {{.Name}}{{.Initializer}};
1515
{{- end}}
1616
}

src/gen/java/com/uber/cadence/BadBinaries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
@Data
88
@Accessors(chain = true)
99
public class BadBinaries {
10-
private Map<String, BadBinaryInfo> binaries;
10+
private Map<String, BadBinaryInfo> binaries = new HashMap<>();;
1111
}

src/gen/java/com/uber/cadence/CrossClusterApplyParentClosePolicyRequestAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
@Data
88
@Accessors(chain = true)
99
public class CrossClusterApplyParentClosePolicyRequestAttributes {
10-
private List<ApplyParentClosePolicyRequest> children;
10+
private List<ApplyParentClosePolicyRequest> children = new ArrayList<>();;
1111
}

src/gen/java/com/uber/cadence/CrossClusterApplyParentClosePolicyResponseAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
@Data
88
@Accessors(chain = true)
99
public class CrossClusterApplyParentClosePolicyResponseAttributes {
10-
private List<ApplyParentClosePolicyResult> childrenStatus;
10+
private List<ApplyParentClosePolicyResult> childrenStatus = new ArrayList<>();;
1111
}

src/gen/java/com/uber/cadence/CrossClusterStartChildExecutionRequestAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public class CrossClusterStartChildExecutionRequestAttributes {
1212
private long initiatedEventID;
1313
private StartChildWorkflowExecutionInitiatedEventAttributes initiatedEventAttributes;
1414
private String targetRunID;
15-
private Map<String, String> partitionConfig;
15+
private Map<String, String> partitionConfig = new HashMap<>();;
1616
}

src/gen/java/com/uber/cadence/DescribeHistoryHostResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Accessors(chain = true)
99
public class DescribeHistoryHostResponse {
1010
private int numberOfShards;
11-
private List<Integer> shardIDs;
11+
private List<Integer> shardIDs = new ArrayList<>();;
1212
private DomainCacheInfo domainCache;
1313
private String shardControllerStatus;
1414
private String address;

src/gen/java/com/uber/cadence/DescribeQueueResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
@Data
88
@Accessors(chain = true)
99
public class DescribeQueueResponse {
10-
private List<String> processingQueueStates;
10+
private List<String> processingQueueStates = new ArrayList<>();;
1111
}

src/gen/java/com/uber/cadence/DescribeShardDistributionResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
@Accessors(chain = true)
99
public class DescribeShardDistributionResponse {
1010
private int numberOfShards;
11-
private Map<Integer, String> shards;
11+
private Map<Integer, String> shards = new HashMap<>();;
1212
}

0 commit comments

Comments
 (0)