Pass string to ObjectMapper instead of InputStream

Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
pull/531/head
Igor Vinokur 2023-07-11 14:13:09 +03:00
parent aee2079322
commit e79839bc9f
5 changed files with 39 additions and 13 deletions

View File

@ -116,7 +116,9 @@ public class AzureDevOpsApiClient {
userDataRequest,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), AzureDevOpsUser.class);
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, AzureDevOpsUser.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}

View File

@ -176,7 +176,9 @@ public class HttpBitbucketServerApiClient implements BitbucketServerApiClient {
request,
inputStream -> {
try {
return OM.readValue(inputStream, BitbucketUser.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OM.readValue(result, BitbucketUser.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -230,7 +232,9 @@ public class HttpBitbucketServerApiClient implements BitbucketServerApiClient {
request,
inputStream -> {
try {
return OM.readValue(inputStream, String.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OM.readValue(result, String.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -271,7 +275,9 @@ public class HttpBitbucketServerApiClient implements BitbucketServerApiClient {
request,
inputStream -> {
try {
return OM.readValue(inputStream, BitbucketPersonalAccessToken.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OM.readValue(result, BitbucketPersonalAccessToken.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -313,7 +319,9 @@ public class HttpBitbucketServerApiClient implements BitbucketServerApiClient {
request,
inputStream -> {
try {
return OM.readValue(inputStream, BitbucketPersonalAccessToken.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OM.readValue(result, BitbucketPersonalAccessToken.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -388,7 +396,9 @@ public class HttpBitbucketServerApiClient implements BitbucketServerApiClient {
request,
inputStream -> {
try {
return OM.readValue(inputStream, typeReference);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OM.readValue(result, typeReference);
} catch (IOException e) {
throw new UncheckedIOException(e);
}

View File

@ -108,7 +108,9 @@ public class BitbucketApiClient {
request,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), BitbucketUser.class);
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, BitbucketUser.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -154,7 +156,9 @@ public class BitbucketApiClient {
request,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), BitbucketUserEmail.class);
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, BitbucketUserEmail.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}

View File

@ -111,7 +111,9 @@ public class GithubApiClient {
request,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), GithubUser.class);
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, GithubUser.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -140,7 +142,9 @@ public class GithubApiClient {
request,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), GithubPullRequest.class);
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, GithubPullRequest.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -181,7 +185,9 @@ public class GithubApiClient {
request,
response -> {
try {
return OBJECT_MAPPER.readValue(response.body(), GithubCommit[].class)[0];
String result =
CharStreams.toString(new InputStreamReader(response.body(), Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, GithubCommit[].class)[0];
} catch (IOException e) {
throw new UncheckedIOException(e);
}

View File

@ -78,7 +78,9 @@ public class GitlabApiClient {
request,
inputStream -> {
try {
return OBJECT_MAPPER.readValue(inputStream, GitlabUser.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, GitlabUser.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@ -100,7 +102,9 @@ public class GitlabApiClient {
request,
inputStream -> {
try {
return OBJECT_MAPPER.readValue(inputStream, GitlabOauthTokenInfo.class);
String result =
CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));
return OBJECT_MAPPER.readValue(result, GitlabOauthTokenInfo.class);
} catch (IOException e) {
throw new UncheckedIOException(e);
}