Skip to content

Commit

Permalink
Two tiny fixes for Java Vertx client (#3683)
Browse files Browse the repository at this point in the history
* two tiny fixes:

1.) ApiClient already defines and configures an objectMapper to not fail on unknown properties, but it is not used when parsing the response. The fix uses the pre-configured object mapper instead of the vertx default one

2.) When an operation has no response (or just ones without content), the accept array passed to ApiClient is emtpy. This makes the null check in ApiClient useless, as it still tries to set a null Accept header, which is refused with an NPE. Amend the check with .length > 0 to catch this case.

* update generated client as required by contributor guidelines
  • Loading branch information
FlorianBruckner authored and wing328 committed Aug 25, 2019
1 parent 859df23 commit 16ac05d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public class ApiClient {
updateParamsForAuth(authNames, queryParams, headerParams);
if (accepts != null) {
if (accepts != null && accepts.length > 0) {
headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts));
}

Expand Down Expand Up @@ -579,7 +579,7 @@ public class ApiClient {
return;
} else {
try {
resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType);
resultContent = this.objectMapper.readValue(httpResponse.bodyAsString(), returnType);
result = Future.succeededFuture(resultContent);
} catch (Exception e) {
result = ApiException.fail(new DecodeException("Failed to decode:" + e.getMessage(), e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public <T> void invokeAPI(String path, String method, List<Pair> queryParams, Ob

updateParamsForAuth(authNames, queryParams, headerParams);

if (accepts != null) {
if (accepts != null && accepts.length > 0) {
headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts));
}

Expand Down Expand Up @@ -575,7 +575,7 @@ protected <T> Handler<AsyncResult<HttpResponse<Buffer>>> buildResponseHandler(Ty
return;
} else {
try {
resultContent = Json.mapper.readValue(httpResponse.bodyAsString(), returnType);
resultContent = this.objectMapper.readValue(httpResponse.bodyAsString(), returnType);
result = Future.succeededFuture(resultContent);
} catch (Exception e) {
result = ApiException.fail(new DecodeException("Failed to decode:" + e.getMessage(), e));
Expand Down

0 comments on commit 16ac05d

Please sign in to comment.