diff --git a/src/main/java/de/siegmar/logbackgelf/GelfMessage.java b/src/main/java/de/siegmar/logbackgelf/GelfMessage.java index 2c39f75..b13a6c5 100644 --- a/src/main/java/de/siegmar/logbackgelf/GelfMessage.java +++ b/src/main/java/de/siegmar/logbackgelf/GelfMessage.java @@ -91,9 +91,8 @@ public StringBuilder toJSON() { .appendToJSONUnquoted("timestamp", timestampToGelfNotation(timestamp)) .appendToJSONUnquoted("level", level); - for (final Map.Entry entry : additionalFields.entrySet()) { - jsonEncoder.appendToJSON('_' + entry.getKey(), entry.getValue()); - } + additionalFields + .forEach((key, value) -> jsonEncoder.appendToJSON('_' + key, value)); } return sb; diff --git a/src/test/java/de/siegmar/logbackgelf/custom/CustomGelfEncoder.java b/src/test/java/de/siegmar/logbackgelf/custom/CustomGelfEncoder.java index c174b79..1897b1e 100644 --- a/src/test/java/de/siegmar/logbackgelf/custom/CustomGelfEncoder.java +++ b/src/test/java/de/siegmar/logbackgelf/custom/CustomGelfEncoder.java @@ -19,11 +19,7 @@ package de.siegmar.logbackgelf.custom; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; -import java.security.DigestOutputStream; import java.security.MessageDigest; import java.util.Map; @@ -49,14 +45,7 @@ protected GelfMessage buildGelfMessage(final long timestamp, final int logLevel, private static String buildHash(final GelfMessage gelfMessage) { final MessageDigest digest = new SHA256.Digest(); - - try (DigestOutputStream dos = new DigestOutputStream(OutputStream.nullOutputStream(), digest)) { - dos.write(gelfMessage.toJSON().toString().getBytes(StandardCharsets.UTF_8)); - } catch (final IOException e) { - throw new UncheckedIOException(e); - } - - return toHex(digest.digest()); + return toHex(digest.digest(gelfMessage.toJSON().toString().getBytes(StandardCharsets.UTF_8))); } private static String toHex(final byte[] data) {