Source:
<code>public void write(Iterable<QueryResult> results) { logger.debug("Export to '{}' results {}", graphiteHttpUrl, results); HttpURLConnection urlConnection = null; OutputStreamWriter urlWriter = null; try { StringBuilder sbUrlWriter = new StringBuilder("data="); for (QueryResult result : results) { String msg = metricPathPrefix + result.getName() + " " + result.getValue() + " " + result.getEpoch(TimeUnit.SECONDS) + "\n"; logger.debug("Export '{}'", msg); sbUrlWriter.append(msg); } if (sbUrlWriter.length() > 5) { urlConnection = (HttpURLConnection) graphiteHttpUrl.openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setDoOutput(true); <START> urlWriter = new OutputStreamWriter(urlConnection.getOutputStream()); <END> urlWriter.write(sbUrlWriter.toString()); urlWriter.flush(); IoUtils2.closeQuietly(urlWriter); int responseCode = urlConnection.getResponseCode(); if (responseCode != 200) { logger.warn("Failure {}:'{}' to send result to Graphite HTTP proxy'{}' ", responseCode, urlConnection.getResponseMessage(), graphiteHttpUrl); } if (logger.isTraceEnabled()) { IoUtils2.copy(urlConnection.getInputStream(), System.out); } } } catch (Exception e) { logger.warn("Failure to send result to Graphite HTTP proxy '{}'", graphiteHttpUrl, e); } finally { if (urlConnection != null) { try { InputStream in = urlConnection.getInputStream(); IoUtils2.copy(in, IoUtils2.nullOutputStream()); IoUtils2.closeQuietly(in); InputStream err = urlConnection.getErrorStream(); if (err != null) { IoUtils2.copy(err, IoUtils2.nullOutputStream()); IoUtils2.closeQuietly(err); } } catch (IOException e) { logger.warn("Exception flushing http connection", e); } } } }</code><technical_language>a charset fix FindBugs "Found reliance default encoding in org.jmxtrans.embedded.output.GraphiteHttpWriter.write(Iterable): new java.io.OutputStreamWriter(OutputStream) org.jmxtrans.embedded.output.GraphiteHttpWriter GraphiteHttpWriter.java:..."</technical_language>

Target:
public void write(Iterable<QueryResult> results) { logger.debug("Export to '{}' results {}", graphiteHttpUrl, results); HttpURLConnection urlConnection = null; OutputStreamWriter urlWriter = null; try { StringBuilder sbUrlWriter = new StringBuilder(""); for (QueryResult result : results) { String msg = metricPathPrefix + result.getName() + " " + result.getValue() + " " + result.getEpoch(TimeUnit.SECONDS) + "\n"; logger.debug("Export '{}'", msg); sbUrlWriter.append(msg); } if (sbUrlWriter.length() > 0) { sbUrlWriter.insert(0, "data="); urlConnection = (HttpURLConnection) graphiteHttpUrl.openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setDoOutput(true); urlWriter = new OutputStreamWriter(urlConnection.getOutputStream(), Charset.forName("UTF-8")); urlWriter.write(sbUrlWriter.toString()); urlWriter.flush(); IoUtils2.closeQuietly(urlWriter); int responseCode = urlConnection.getResponseCode(); if (responseCode != 200) { logger.warn("Failure {}:'{}' to send result to Graphite HTTP proxy'{}' ", responseCode, urlConnection.getResponseMessage(), graphiteHttpUrl); } if (logger.isTraceEnabled()) { IoUtils2.copy(urlConnection.getInputStream(), System.out); } } } catch (Exception e) { logger.warn("Failure to send result to Graphite HTTP proxy '{}'", graphiteHttpUrl, e); } finally { if (urlConnection != null) { try { InputStream in = urlConnection.getInputStream(); IoUtils2.copy(in, IoUtils2.nullOutputStream()); IoUtils2.closeQuietly(in); InputStream err = urlConnection.getErrorStream(); if (err != null) { IoUtils2.copy(err, IoUtils2.nullOutputStream()); IoUtils2.closeQuietly(err); } } catch (IOException e) { logger.warn("Exception flushing http connection", e); } } } }