Skip to content

Commit

Permalink
remove thread unsafe statusCode and responseHeaders instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronforest-wf committed Jul 2, 2024
1 parent 376505c commit 4dbf174
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {

private Map<String, Authentication> authentications;

private int statusCode;
private Map<String, List<String>> responseHeaders;

private DateFormat dateFormat;

// Methods that can have a request body
Expand Down Expand Up @@ -274,23 +271,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return this;
}

/**
* Gets the status code of the previous request
*
* @return Status code
*/
public int getStatusCode() {
return statusCode;
}

/**
* Gets the response headers of the previous request
* @return Response headers
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}

/**
* Get authentications (key: authentication name, value: authentication).
* @return Map of authentication
Expand Down Expand Up @@ -863,6 +843,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
// convert input stream to string
return (T) EntityUtils.toString(entity);
} else {
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
response.getCode(),
Expand Down Expand Up @@ -1008,16 +989,16 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}

protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
statusCode = response.getCode();
int statusCode = response.getCode();
if (statusCode == HttpStatus.SC_NO_CONTENT) {
return null;
}

responseHeaders = transformResponseHeaders(response.getHeaders());
if (isSuccessfulStatus(statusCode)) {
return this.deserialize(response, returnType);
} else {
String message = EntityUtils.toString(response.getEntity());
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(message, statusCode, responseHeaders, message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public class ApiClient extends JavaTimeFormatter {

private Map<String, Authentication> authentications;

private int statusCode;
private Map<String, List<String>> responseHeaders;

private DateFormat dateFormat;

// Methods that can have a request body
Expand Down Expand Up @@ -245,23 +242,6 @@ public ApiClient setServerVariables(Map<String, String> serverVariables) {
return this;
}

/**
* Gets the status code of the previous request
*
* @return Status code
*/
public int getStatusCode() {
return statusCode;
}

/**
* Gets the response headers of the previous request
* @return Response headers
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}

/**
* Get authentications (key: authentication name, value: authentication).
* @return Map of authentication
Expand Down Expand Up @@ -781,6 +761,7 @@ public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueT
// convert input stream to string
return (T) EntityUtils.toString(entity);
} else {
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
response.getCode(),
Expand Down Expand Up @@ -926,16 +907,16 @@ protected Cookie buildCookie(String key, String value, URI uri) {
}

protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
statusCode = response.getCode();
int statusCode = response.getCode();
if (statusCode == HttpStatus.SC_NO_CONTENT) {
return null;
}

responseHeaders = transformResponseHeaders(response.getHeaders());
if (isSuccessfulStatus(statusCode)) {
return this.deserialize(response, returnType);
} else {
String message = EntityUtils.toString(response.getEntity());
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(message, statusCode, responseHeaders, message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ public class ApiClient extends JavaTimeFormatter {

private Map<String, Authentication> authentications;

private int statusCode;
private Map<String, List<String>> responseHeaders;

private DateFormat dateFormat;

// Methods that can have a request body
Expand Down Expand Up @@ -293,23 +290,6 @@ public ApiClient setServerVariables(Map<String, String> serverVariables) {
return this;
}

/**
* Gets the status code of the previous request
*
* @return Status code
*/
public int getStatusCode() {
return statusCode;
}

/**
* Gets the response headers of the previous request
* @return Response headers
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}

/**
* Get authentications (key: authentication name, value: authentication).
* @return Map of authentication
Expand Down Expand Up @@ -874,6 +854,7 @@ public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueT
// convert input stream to string
return (T) EntityUtils.toString(entity);
} else {
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
response.getCode(),
Expand Down Expand Up @@ -1019,16 +1000,16 @@ protected Cookie buildCookie(String key, String value, URI uri) {
}

protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
statusCode = response.getCode();
int statusCode = response.getCode();
if (statusCode == HttpStatus.SC_NO_CONTENT) {
return null;
}

responseHeaders = transformResponseHeaders(response.getHeaders());
if (isSuccessfulStatus(statusCode)) {
return this.deserialize(response, returnType);
} else {
String message = EntityUtils.toString(response.getEntity());
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
throw new ApiException(message, statusCode, responseHeaders, message);
}
}
Expand Down

0 comments on commit 4dbf174

Please sign in to comment.