pawelpasterz commented on a change in pull request #12102:
URL: https://github.com/apache/beam/pull/12102#discussion_r446176218
##########
File path:
sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/publishing/InfluxDBPublisher.java
##########
@@ -146,16 +157,29 @@ private static HttpPost providePOSTRequest(final
InfluxDBSettings settings) {
private static void executeWithVerification(
final HttpPost postRequest, final HttpClientBuilder builder) throws
IOException {
try (final CloseableHttpResponse response =
builder.build().execute(postRequest)) {
- is2xx(response.getStatusLine().getStatusCode());
+ is2xx(response);
}
}
- private static void is2xx(final int code) throws IOException {
+ private static void is2xx(final HttpResponse response) throws IOException {
+ final int code = response.getStatusLine().getStatusCode();
if (code < 200 || code >= 300) {
- throw new IOException("Response code: " + code);
+ throw new IOException(
+ "Response code: " + code + ". Reason: " +
getErrorMessage(response.getEntity()));
}
}
+ private static String getErrorMessage(final HttpEntity entity) throws
IOException {
+ final Header encodingHeader = entity.getContentEncoding();
Review comment:
Yes, that's why I check encoding type to be prepared for case when
influx would stop sending us JSON (and start something else)
```
final Charset encoding =
encodingHeader == null
? StandardCharsets.UTF_8
: Charsets.toCharset(encodingHeader.getValue());
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]