Skip to content

Commit

Permalink
java 8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
chDame committed Mar 30, 2023
1 parent 718a9d7 commit da268f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/io/camunda/operate/CamundaOperateClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.camunda.operate;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpPost;
Expand Down Expand Up @@ -102,7 +105,12 @@ private CloseableHttpResponse execute(CloseableHttpClient httpClient, ClassicHtt
private OperateException createDetailedException(CloseableHttpResponse response, ClassicHttpRequest request) throws IOException {
String details = "";
if (request instanceof HttpPost) {
details+= "; Body : " + new String(((HttpPost) request).getEntity().getContent().readAllBytes(), StandardCharsets.UTF_8);
InputStream content = ((HttpPost) request).getEntity().getContent();
String body = new BufferedReader(
new InputStreamReader(content, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"));
details+= "; Body : " + body;
}
return new OperateException(request.getPath()+" : "+response.getCode()+" "+response.getReasonPhrase()+details);
}
Expand Down

0 comments on commit da268f0

Please sign in to comment.