Skip to content

Commit 9c67b6d

Browse files
committed
Avoid NPE setting null on optional lists
1 parent 6b8f138 commit 9c67b6d

666 files changed

Lines changed: 3567 additions & 1783 deletions

File tree

Some content is hidden

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

.generator/src/generator/templates/modelSimple.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,18 @@ public class {{ name }} {%- if model.get("x-generate-alias-as-model") %} extends
120120
{%- else %}
121121
{%- if schema.get("items")|is_model and not schema|is_primitive %}
122122
{%- set itemsDataType = get_type(schema.get("items")) %}
123+
{%- if not isRequired %}
124+
if ({{ variableName }} != null) {
125+
{%- endif %}
123126
for ({{ itemsDataType }} item : {{ variableName }}) {
124127
{%- if schema.enum is defined %}
125128
this.unparsed |= !item.isValid();
126129
{%- endif %}
127130
this.unparsed |= item.unparsed;
128131
}
132+
{%- if not isRequired %}
133+
}
134+
{%- endif %}
129135
{%- endif %}
130136
{%- endif %}
131137
{%- endif %}

src/main/java/com/datadog/api/client/v1/model/AWSAccountListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class AWSAccountListResponse {
2929

3030
public AWSAccountListResponse accounts(List<AWSAccount> accounts) {
3131
this.accounts = accounts;
32-
for (AWSAccount item : accounts) {
33-
this.unparsed |= item.unparsed;
32+
if (accounts != null) {
33+
for (AWSAccount item : accounts) {
34+
this.unparsed |= item.unparsed;
35+
}
3436
}
3537
return this;
3638
}

src/main/java/com/datadog/api/client/v1/model/AWSEventBridgeAccountConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public void setAccountId(String accountId) {
6060

6161
public AWSEventBridgeAccountConfiguration eventHubs(List<AWSEventBridgeSource> eventHubs) {
6262
this.eventHubs = eventHubs;
63-
for (AWSEventBridgeSource item : eventHubs) {
64-
this.unparsed |= item.unparsed;
63+
if (eventHubs != null) {
64+
for (AWSEventBridgeSource item : eventHubs) {
65+
this.unparsed |= item.unparsed;
66+
}
6567
}
6668
return this;
6769
}

src/main/java/com/datadog/api/client/v1/model/AWSEventBridgeListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public class AWSEventBridgeListResponse {
3535

3636
public AWSEventBridgeListResponse accounts(List<AWSEventBridgeAccountConfiguration> accounts) {
3737
this.accounts = accounts;
38-
for (AWSEventBridgeAccountConfiguration item : accounts) {
39-
this.unparsed |= item.unparsed;
38+
if (accounts != null) {
39+
for (AWSEventBridgeAccountConfiguration item : accounts) {
40+
this.unparsed |= item.unparsed;
41+
}
4042
}
4143
return this;
4244
}

src/main/java/com/datadog/api/client/v1/model/AWSLogsAsyncResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public class AWSLogsAsyncResponse {
3535

3636
public AWSLogsAsyncResponse errors(List<AWSLogsAsyncError> errors) {
3737
this.errors = errors;
38-
for (AWSLogsAsyncError item : errors) {
39-
this.unparsed |= item.unparsed;
38+
if (errors != null) {
39+
for (AWSLogsAsyncError item : errors) {
40+
this.unparsed |= item.unparsed;
41+
}
4042
}
4143
return this;
4244
}

src/main/java/com/datadog/api/client/v1/model/AWSLogsListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public void setAccountId(String accountId) {
6060

6161
public AWSLogsListResponse lambdas(List<AWSLogsLambda> lambdas) {
6262
this.lambdas = lambdas;
63-
for (AWSLogsLambda item : lambdas) {
64-
this.unparsed |= item.unparsed;
63+
if (lambdas != null) {
64+
for (AWSLogsLambda item : lambdas) {
65+
this.unparsed |= item.unparsed;
66+
}
6567
}
6668
return this;
6769
}

src/main/java/com/datadog/api/client/v1/model/AWSTagFilterListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class AWSTagFilterListResponse {
2929

3030
public AWSTagFilterListResponse filters(List<AWSTagFilter> filters) {
3131
this.filters = filters;
32-
for (AWSTagFilter item : filters) {
33-
this.unparsed |= item.unparsed;
32+
if (filters != null) {
33+
for (AWSTagFilter item : filters) {
34+
this.unparsed |= item.unparsed;
35+
}
3436
}
3537
return this;
3638
}

src/main/java/com/datadog/api/client/v1/model/ApiKeyListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class ApiKeyListResponse {
2929

3030
public ApiKeyListResponse apiKeys(List<ApiKey> apiKeys) {
3131
this.apiKeys = apiKeys;
32-
for (ApiKey item : apiKeys) {
33-
this.unparsed |= item.unparsed;
32+
if (apiKeys != null) {
33+
for (ApiKey item : apiKeys) {
34+
this.unparsed |= item.unparsed;
35+
}
3436
}
3537
return this;
3638
}

src/main/java/com/datadog/api/client/v1/model/ApmStatsQueryDefinition.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ public ApmStatsQueryDefinition(
7373

7474
public ApmStatsQueryDefinition columns(List<ApmStatsQueryColumnType> columns) {
7575
this.columns = columns;
76-
for (ApmStatsQueryColumnType item : columns) {
77-
this.unparsed |= item.unparsed;
76+
if (columns != null) {
77+
for (ApmStatsQueryColumnType item : columns) {
78+
this.unparsed |= item.unparsed;
79+
}
7880
}
7981
return this;
8082
}

src/main/java/com/datadog/api/client/v1/model/ApplicationKeyListResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class ApplicationKeyListResponse {
2929

3030
public ApplicationKeyListResponse applicationKeys(List<ApplicationKey> applicationKeys) {
3131
this.applicationKeys = applicationKeys;
32-
for (ApplicationKey item : applicationKeys) {
33-
this.unparsed |= item.unparsed;
32+
if (applicationKeys != null) {
33+
for (ApplicationKey item : applicationKeys) {
34+
this.unparsed |= item.unparsed;
35+
}
3436
}
3537
return this;
3638
}

0 commit comments

Comments
 (0)