Skip to content

Commit 1b18c94

Browse files
authored
Make sure element is not null when checking unparsed (#1163)
We need to bne sure it's not null.
1 parent ce9bab5 commit 1b18c94

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.generator/templates/libraries/jersey2/pojo.mustache

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
111111
{{/requiredVars}}
112112
) {
113113
{{#requiredVars}}
114-
this.{{name}} = {{name}};{{#allowableValues}}
114+
this.{{name}} = {{name}};{{#isNullable}}
115+
if ({{name}} != null) {
116+
{{/isNullable}}{{#allowableValues}}
115117
this.unparsed |= !{{name}}.isValid();{{/allowableValues}}{{#isModel}}{{^isPrimitiveType}}
116118
this.unparsed |= {{name}}.unparsed;{{/isPrimitiveType}}{{/isModel}}
119+
{{#isNullable}}
120+
}
121+
{{/isNullable}}
117122
{{/requiredVars}}
118123
}
119124
{{/hasRequired}}
@@ -139,6 +144,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
139144
{{^vendorExtensions.x-is-jackson-optional-nullable}}
140145
this.{{name}} = {{name}};
141146
{{^isArray}}
147+
{{#isNullable}}
148+
if ({{name}} != null) {
149+
{{/isNullable}}
142150
{{#allowableValues}}
143151
{{^isPrimitiveType}}
144152
this.unparsed |= !{{name}}.isValid();
@@ -149,6 +157,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
149157
this.unparsed |= {{name}}.unparsed;
150158
{{/isPrimitiveType}}
151159
{{/isModel}}
160+
{{#isNullable}}
161+
}
162+
{{/isNullable}}
152163
{{/isArray}}
153164
{{#isArray}}
154165
{{#items.isModel}}

src/main/java/com/datadog/api/v2/client/model/LogsArchiveAttributes.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ public LogsArchiveAttributes(
6161
@JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name,
6262
@JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) {
6363
this.destination = destination;
64-
this.unparsed |= destination.unparsed;
64+
if (destination != null) {
65+
66+
this.unparsed |= destination.unparsed;
67+
}
6568
this.name = name;
6669
this.query = query;
6770
}
6871

6972
public LogsArchiveAttributes destination(LogsArchiveDestination destination) {
7073
this.destination = destination;
71-
this.unparsed |= destination.unparsed;
74+
if (destination != null) {
75+
this.unparsed |= destination.unparsed;
76+
}
7277
return this;
7378
}
7479

0 commit comments

Comments
 (0)