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);