code: @Override
    public void emitted(Map<String, Object>log)  {
      if (socket == null) return;
  
      ByteArrayOutputStream messageBuffer = new ByteArrayOutputStream(1024);
      Writer messageWriter = null;
      try {
        messageWriter = new OutputStreamWriter(messageBuffer, "utf-8");
        JsonWriter jsonWriter = new JsonWriter(messageWriter);
        jsonWriter.write(log);
        messageWriter.write("\n");
      } catch (IOException e) {
        throw new InternalSpockError(e);
      } finally {
        IoUtil.closeQuietly(messageWriter);
      }
  
      ByteArrayOutputStream sizeBuffer = new ByteArrayOutputStream();
      Writer sizeWriter = null;
      try {
        sizeWriter = new OutputStreamWriter(sizeBuffer, "utf-8");
        sizeWriter.write(String.valueOf(messageBuffer.size()));
        sizeWriter.write("\n");
      } catch (IOException e) {
        throw new InternalSpockError(e);
      } finally {
        IoUtil.closeQuietly(sizeWriter);
      }
  
      try {
        socket.getOutputStream().write(sizeBuffer.toByteArray());
        socket.getOutputStream().write(messageBuffer.toByteArray());
        socket.getOutputStream().flush();
      } catch (Exception e) {
        IoUtil.closeQuietly(socket);
        socket = null;
        throw new ExtensionException("Error sending data to report server. " +
            "Server address: $reportServerAddress Server port: $reportServerPort", e);
      }
    }
docs: TODO: reuse buffers?