Skip to content

Commit f07c2fd

Browse files
committed
Merge branch 'feat/unhandled-sessions-protocol' into feat/unhandled-sessions-cache
2 parents 21fa60d + 59717b2 commit f07c2fd

1 file changed

Lines changed: 59 additions & 20 deletions

File tree

sentry/src/main/java/io/sentry/Session.java

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,46 @@ public Session(
9999
final @Nullable String environment,
100100
final @NotNull String release,
101101
final @Nullable String abnormalMechanism) {
102+
this(
103+
status,
104+
started,
105+
timestamp,
106+
errorCount,
107+
distinctId,
108+
sessionId,
109+
init,
110+
sequence,
111+
duration,
112+
ipAddress,
113+
userAgent,
114+
environment,
115+
release,
116+
abnormalMechanism,
117+
false);
118+
}
119+
120+
/**
121+
* Canonical constructor. Kept private so {@code nonTerminatingUnhandledError} stays off the
122+
* public API: it is internal bookkeeping that only {@link #clone()} and {@link Deserializer} need
123+
* to restore, and a public overload carrying it would let callers fabricate a session claiming an
124+
* unhandled error that was never counted.
125+
*/
126+
private Session(
127+
final @NotNull State status,
128+
final @NotNull Date started,
129+
final @Nullable Date timestamp,
130+
final int errorCount,
131+
final @Nullable String distinctId,
132+
final @Nullable String sessionId,
133+
final @Nullable Boolean init,
134+
final @Nullable Long sequence,
135+
final @Nullable Double duration,
136+
final @Nullable String ipAddress,
137+
final @Nullable String userAgent,
138+
final @Nullable String environment,
139+
final @NotNull String release,
140+
final @Nullable String abnormalMechanism,
141+
final boolean nonTerminatingUnhandledError) {
102142
this.status = status;
103143
this.started = started;
104144
this.timestamp = timestamp;
@@ -113,6 +153,7 @@ public Session(
113153
this.environment = environment;
114154
this.release = release;
115155
this.abnormalMechanism = abnormalMechanism;
156+
this.nonTerminatingUnhandledError = nonTerminatingUnhandledError;
116157
}
117158

118159
public Session(
@@ -368,24 +409,22 @@ private long getSequenceTimestamp(final @NotNull Date timestamp) {
368409
*/
369410
@SuppressWarnings("MissingOverride")
370411
public @NotNull Session clone() {
371-
final Session session =
372-
new Session(
373-
status,
374-
started,
375-
timestamp,
376-
errorCount.get(),
377-
distinctId,
378-
sessionId,
379-
init,
380-
sequence,
381-
duration,
382-
ipAddress,
383-
userAgent,
384-
environment,
385-
release,
386-
abnormalMechanism);
387-
session.nonTerminatingUnhandledError = nonTerminatingUnhandledError;
388-
return session;
412+
return new Session(
413+
status,
414+
started,
415+
timestamp,
416+
errorCount.get(),
417+
distinctId,
418+
sessionId,
419+
init,
420+
sequence,
421+
duration,
422+
ipAddress,
423+
userAgent,
424+
environment,
425+
release,
426+
abnormalMechanism,
427+
nonTerminatingUnhandledError);
389428
}
390429

391430
// JsonSerializable
@@ -604,8 +643,8 @@ public static final class Deserializer implements JsonDeserializer<Session> {
604643
userAgent,
605644
environment,
606645
release,
607-
abnormalMechanism);
608-
session.nonTerminatingUnhandledError = nonTerminatingUnhandledError;
646+
abnormalMechanism,
647+
nonTerminatingUnhandledError);
609648
session.setUnknown(unknown);
610649
reader.endObject();
611650
return session;

0 commit comments

Comments
 (0)