Skip to content

Commit 9fce32c

Browse files
committed
Sets default values for ServerLogItem
Ensures that the ServerLogItem properties are initialized with default values when retrieving them from the context. This prevents null pointer exceptions or unexpected behavior when these properties are not explicitly set in the context.
1 parent e33a4fc commit 9fce32c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.io.Serializable;
1313
import java.text.SimpleDateFormat;
14+
import java.time.Instant;
1415
import java.util.Date;
1516
import java.util.HashMap;
1617
import java.util.Map;
@@ -44,11 +45,11 @@ public ServerLogItem(Map<String, Object> properties) {
4445
}
4546

4647
this.serverId = (String) context.getOrDefault("serverId", "");
47-
this.id = (Long) context.getOrDefault("id", "");
48+
this.id = (Long) context.getOrDefault("id", 0L);
4849
this.channelId = (String) context.getOrDefault("channelId", "");
4950
this.channelName = (String) context.getOrDefault("channelName", "");
5051
this.level = (String) context.getOrDefault("level", "");
51-
this.date = (Date) context.getOrDefault("date", "");
52+
this.date = (Date) context.getOrDefault("date", Date.from(Instant.now()));
5253
this.threadName = (String) context.getOrDefault("threadName", "");
5354
this.category = (String) context.getOrDefault("category", "");
5455
this.lineNumber = (String) context.getOrDefault("lineNumber", "");

0 commit comments

Comments
 (0)