Skip to content

Commit f01f5cb

Browse files
laballabLuis Ballabeni
authored andcommitted
Fix OpenAPITools#6157: Updated native template to fix null async return (OpenAPITools#6168)
* Fix OpenAPITools#6157: Updated native template to fix null async return Should fix issue: OpenAPITools#6157 * fixed uncaught json exception in java native api gen * cleaning up Co-authored-by: Luis Ballabeni <[email protected]>
1 parent d788a26 commit f01f5cb

File tree

1 file changed

+12
-8
lines changed
  • modules/openapi-generator/src/main/resources/Java/libraries/native

1 file changed

+12
-8
lines changed

modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,18 @@ public class {{classname}} {
180180
localVarResponse.body())
181181
);
182182
} else {
183-
return CompletableFuture.completedFuture(
184-
{{#returnValue}}
185-
memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {})
186-
{{/returnValue}}
187-
{{^returnValue}}
188-
null
189-
{{/returnValue}}
190-
);
183+
try {
184+
return CompletableFuture.completedFuture(
185+
{{#returnType}}
186+
memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {})
187+
{{/returnType}}
188+
{{^returnType}}
189+
null
190+
{{/returnType}}
191+
);
192+
} catch (IOException e) {
193+
return CompletableFuture.failedFuture(new ApiException(e));
194+
}
191195
}
192196
});
193197
{{/asyncNative}}

0 commit comments

Comments
 (0)