Skip to content

Commit fa77ab1

Browse files
committed
Added unique id to log message to avoid reprocessing server side
1 parent caa13b4 commit fa77ab1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/main/java/com/stackify/api/LogMsg.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.stackify.api;
1717

18+
import java.util.UUID;
19+
1820
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1921
import com.fasterxml.jackson.annotation.JsonInclude;
2022
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -82,6 +84,12 @@ public class LogMsg {
8284
@JsonProperty("SrcLine")
8385
private final Integer srcLine;
8486

87+
/**
88+
* The log message id
89+
*/
90+
@JsonProperty("id")
91+
private final String id;
92+
8593
/**
8694
* @return the msg
8795
*/
@@ -145,6 +153,13 @@ public Integer getSrcLine() {
145153
return srcLine;
146154
}
147155

156+
/**
157+
* @return the id
158+
*/
159+
public String getId() {
160+
return id;
161+
}
162+
148163
/**
149164
* @return An instance of Builder, based on current class state
150165
*/
@@ -174,6 +189,7 @@ private LogMsg(final Builder builder) {
174189
this.transId = builder.transId;
175190
this.srcMethod = builder.srcMethod;
176191
this.srcLine = builder.srcLine;
192+
this.id = UUID.randomUUID().toString();
177193
}
178194

179195
/**

src/test/java/com/stackify/api/LogMsgTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public void testBuilder() {
6565
Assert.assertEquals(srcMethod, logMsg.getSrcMethod());
6666
Assert.assertEquals(srcLine, logMsg.getSrcLine());
6767

68+
Assert.assertNotNull(logMsg.getId());
69+
6870
LogMsg logMsgCopy = logMsg.toBuilder().build();
6971

7072
Assert.assertNotNull(logMsgCopy);

0 commit comments

Comments
 (0)