[ 
https://issues.apache.org/jira/browse/BEAM-8133?focusedWorklogId=451556&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-451556
 ]

ASF GitHub Bot logged work on BEAM-8133:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jun/20 13:15
            Start Date: 26/Jun/20 13:15
    Worklog Time Spent: 10m 
      Work Description: 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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 451556)
    Time Spent: 14h 10m  (was: 14h)

> Create metrics publisher in Java SDK
> ------------------------------------
>
>                 Key: BEAM-8133
>                 URL: https://issues.apache.org/jira/browse/BEAM-8133
>             Project: Beam
>          Issue Type: Sub-task
>          Components: testing
>            Reporter: Kamil Wasilewski
>            Assignee: Pawel Pasterz
>            Priority: P2
>             Fix For: Not applicable
>
>          Time Spent: 14h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to