Skip to content

Commit

Permalink
Fixed NPE when no parameters are set
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaehren committed Sep 23, 2024
1 parent b7b0383 commit f71cdc7
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,24 @@ public StringBuilder toSerializable(LogEvent event, StringBuilder buffer) {
Class<byte[]> bArrayClass = byte[].class;

// Iterate over each parameter of a {@Link LogEvent} to find all ByteArrays
for (Object param : event.getMessage().getParameters()) {

// Replace all ByteArrays with the String representation of the ByteArray calculated
// by the ArrayConverter.
if (param != null && bArrayClass == param.getClass()) {
buffer.replace(
buffer.indexOf(Arrays.toString((byte[]) param)),
buffer.indexOf(Arrays.toString((byte[]) param))
+ Arrays.toString((byte[]) param).length(),
ArrayConverter.bytesToHexString(
(byte[]) param, Builder.prettyPrinting, Builder.initNewLine));
if (event.getMessage().getParameters() != null) {
for (Object param : event.getMessage().getParameters()) {

// Replace all ByteArrays with the String representation of the ByteArray
// calculated
// by the ArrayConverter.
if (param != null && bArrayClass == param.getClass()) {
buffer.replace(
buffer.indexOf(Arrays.toString((byte[]) param)),
buffer.indexOf(Arrays.toString((byte[]) param))
+ Arrays.toString((byte[]) param).length(),
ArrayConverter.bytesToHexString(
(byte[]) param,
Builder.prettyPrinting,
Builder.initNewLine));
}
}
}

return buffer;
}

Expand Down

0 comments on commit f71cdc7

Please sign in to comment.