Skip to content

Commit

Permalink
Re-interrupt the thread in the generated code (#4382)
Browse files Browse the repository at this point in the history
* Re-interrupt the thread in the generated code, otherwise the client has to check for
the type of the cause of the thrown exception.

* update samples
  • Loading branch information
feliksik authored and wing328 committed Nov 13, 2019
1 parent 34c715e commit 440e3f3
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public class {{classname}} {
{{#returnType}}
return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {});
{{/returnType}}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public Client call123testSpecialTags(Client body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Client>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public void createXmlItem(XmlItem xmlItem) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -147,7 +150,10 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Boolean>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -190,7 +196,10 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Ap
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<OuterComposite>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -233,7 +242,10 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws ApiException
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<BigDecimal>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -276,7 +288,10 @@ public String fakeOuterStringSerialize(String body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<String>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -321,7 +336,10 @@ public void testBodyWithFileSchema(FileSchemaTestClass body) throws ApiException
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -380,7 +398,10 @@ public void testBodyWithQueryParams(String query, User body) throws ApiException
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -427,7 +448,10 @@ public Client testClientModel(Client body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Client>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -495,7 +519,10 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -559,7 +586,10 @@ public void testEnumParameters(List<String> enumHeaderStringArray, String enumHe
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -633,7 +663,10 @@ public void testGroupParameters(Integer requiredStringGroup, Boolean requiredBoo
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -678,7 +711,10 @@ public void testInlineAdditionalProperties(Map<String, String> param) throws Api
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -726,7 +762,10 @@ public void testJsonFormData(String param, String param2) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -802,7 +841,10 @@ public void testQueryParameterCollectionFormat(List<String> pipe, List<String> i
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public Client testClassname(Client body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Client>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ public void addPet(Pet body) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -146,7 +149,10 @@ public void deletePet(Long petId, String apiKey) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -200,7 +206,10 @@ public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<List<Pet>>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -256,7 +265,10 @@ public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<List<Pet>>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -302,7 +314,10 @@ public Pet getPetById(Long petId) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Pet>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -347,7 +362,10 @@ public void updatePet(Pet body) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -393,7 +411,10 @@ public void updatePetWithForm(Long petId, String name, String status) throws Api
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -441,7 +462,10 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<ModelApiResponse>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -493,7 +517,10 @@ public ModelApiResponse uploadFileWithRequiredFile(Long petId, File requiredFile
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<ModelApiResponse>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public void deleteOrder(String orderId) throws ApiException {
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}

} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -135,7 +138,10 @@ public Map<String, Integer> getInventory() throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Map<String, Integer>>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -181,7 +187,10 @@ public Order getOrderById(Long orderId) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Order>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down Expand Up @@ -228,7 +237,10 @@ public Order placeOrder(Order body) throws ApiException {
}

return memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<Order>() {});
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
throw new ApiException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
Expand Down
Loading

0 comments on commit 440e3f3

Please # to comment.