Skip to content

Commit 20ff3df

Browse files
committed
Update to specify the charset of response
In some Operational Systems (Like IBM Z/OS and IBM Z/Unix) the JRE runs with a charset different of UTF-8, those default charsets produce wrong behavior and truncated responses. To avoid this kind of situations I put the specifc charset in the output writer. This create a consistent response between different platforms. Signed-off-by: João Paulo Binda Delboni <joaopdelboni@gmail.com>
1 parent f48acbb commit 20ff3df

File tree

1 file changed

+2
-1
lines changed
  • simpleclient_httpserver/src/main/java/io/prometheus/client/exporter

1 file changed

+2
-1
lines changed

simpleclient_httpserver/src/main/java/io/prometheus/client/exporter/HTTPServer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.net.HttpURLConnection;
1010
import java.net.InetSocketAddress;
1111
import java.net.URLDecoder;
12+
import java.nio.charset.Charset;
1213
import java.util.List;
1314
import java.util.Set;
1415
import java.util.HashSet;
@@ -61,7 +62,7 @@ public void handle(HttpExchange t) throws IOException {
6162
String contextPath = t.getHttpContext().getPath();
6263
ByteArrayOutputStream response = this.response.get();
6364
response.reset();
64-
OutputStreamWriter osw = new OutputStreamWriter(response);
65+
OutputStreamWriter osw = new OutputStreamWriter(response, Charset.forName("UTF-8"));
6566
if ("/-/healthy".equals(contextPath)) {
6667
osw.write(HEALTHY_RESPONSE);
6768
} else {

0 commit comments

Comments
 (0)