Skip to content

Commit f75dce1

Browse files
committed
getOrDefault
Signed-off-by: Nico Piel <[email protected]>
1 parent 8a0842e commit f75dce1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

server/src/com/mirth/connect/plugins/serverlog/ArrayAppender.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ public void append(LogEvent logEvent) {
3838

3939
String channelId = null;
4040
String channelName = null;
41+
42+
// Check theoretically not necessary, as getContextMap never returns null
43+
// Safety first
4144
if (logEvent.getContextMap() != null) {
42-
if (logEvent.getContextMap().containsKey("channelId")) {
43-
channelId = logEvent.getContextMap().get("channelId");
44-
}
45-
if (logEvent.getContextMap().containsKey("channelName")) {
46-
channelName = logEvent.getContextMap().get("channelName");
47-
}
45+
channelId = logEvent.getContextMap().getOrDefault("channelId", "");
46+
channelName = logEvent.getContextMap().getOrDefault("channelName", "");
4847
}
4948

5049
String level = String.valueOf(logEvent.getLevel());

0 commit comments

Comments
 (0)