[Java][client] Fix feign classcastexception when getting headers (#16745)

* Avoid ClassCastException when getting headers (the header values are Collection<String> and not List<String>)
Delete unused classes

* Remove feign10x

* Add unit test
Refactor to avoid creating the headers map when ApiResponse is not used
This commit is contained in:
Robert Danci
2023-10-10 15:53:32 +09:00
committed by GitHub
parent 494ee489ad
commit 87f9d53c3a
11 changed files with 89 additions and 107 deletions

View File

@@ -1,19 +1,19 @@
package org.openapitools.client.model;
import java.util.Map;
import java.util.List;
import java.util.Collection;
public class ApiResponse<T>{
final private int statusCode;
final private Map<String, List<String>> headers;
final private Map<String, Collection<String>> headers;
final private T data;
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
public ApiResponse(int statusCode, Map<String, Collection<String>> headers) {
this(statusCode, headers, null);
}
@@ -22,7 +22,7 @@ public class ApiResponse<T>{
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
public ApiResponse(int statusCode, Map<String, Collection<String>> headers, T data) {
this.statusCode = statusCode;
this.headers = headers;
this.data = data;
@@ -32,7 +32,7 @@ public class ApiResponse<T>{
return statusCode;
}
public Map<String, List<String>> getHeaders() {
public Map<String, Collection<String>> getHeaders() {
return headers;
}