@@ -93,14 +93,14 @@ private <I, O> O parsedCall(HttpMethod method, String relativePath, Map<String,
9393 if (contentType .startsWith ("application/json" )) {
9494 parsedResult = jsonParser .parseInputStream (response .body (), TypeVariable .class .isAssignableFrom (type .getClass ()) ? Object .class : type );
9595 } else {
96- if ((type . getClass (). isAssignableFrom ( String .class ) || TypeVariable . class . isAssignableFrom ( type . getClass ()) ) && contentType .startsWith ("text/" )) {
96+ if (checkType (type , String .class ) && contentType .startsWith ("text/" )) {
9797 try {
9898 parsedResult = (O )IOUtils .toString (response .body (), defaultCharset ());
9999 } catch (IOException e ) {
100100 throw new ParsingException ("An error occurred while parsing the response." , e );
101101 }
102102 } else {
103- if (( InputStream . class . isAssignableFrom ( type . getClass ()) || type . getClass (). isAssignableFrom ( TypeVariable . class ) )) {
103+ if (checkType ( type , InputStream . class )) {
104104 parsedResult = (O )response .body ();
105105 } else {
106106 throw new UnsupportedContentTypeException (contentType , type );
@@ -114,6 +114,10 @@ private <I, O> O parsedCall(HttpMethod method, String relativePath, Map<String,
114114 return result ;
115115 }
116116
117+ private boolean checkType (Type type , Class <?> expectedClass ) {
118+ return (type .getClass ().isAssignableFrom (Class .class ) && Class .class .cast (type ).isAssignableFrom (expectedClass )) || TypeVariable .class .isAssignableFrom (type .getClass ());
119+ }
120+
117121 private Response callApi (HttpMethod method , String relativePath , Map <String , List <String >> headers , Map <String , List <String >> queryParams , InputStream body ) {
118122 Request request = client .prepareAuthenticatedRequest (host , port , method , relativePath )
119123 .withHeaders (headers )
0 commit comments