Skip to content

Commit 972727c

Browse files
authored
Merge d521a60 into dea75aa
2 parents dea75aa + d521a60 commit 972727c

File tree

6 files changed

+43
-19
lines changed

6 files changed

+43
-19
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/cache/AndroidEnvelopeCache.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public AndroidEnvelopeCache(final @NotNull SentryAndroidOptions options) {
4747
this.currentDateProvider = currentDateProvider;
4848
}
4949

50+
@SuppressWarnings("deprecation")
5051
@Override
5152
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
5253
super.store(envelope, hint);

sentry/api/sentry.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,6 +4357,7 @@ public abstract interface class io/sentry/cache/IEnvelopeCache : java/lang/Itera
43574357
public abstract fun discard (Lio/sentry/SentryEnvelope;)V
43584358
public fun store (Lio/sentry/SentryEnvelope;)V
43594359
public abstract fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
4360+
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
43604361
}
43614362

43624363
public final class io/sentry/cache/PersistingOptionsObserver : io/sentry/IOptionsObserver {
@@ -6659,6 +6660,7 @@ public final class io/sentry/transport/NoOpEnvelopeCache : io/sentry/cache/IEnve
66596660
public static fun getInstance ()Lio/sentry/transport/NoOpEnvelopeCache;
66606661
public fun iterator ()Ljava/util/Iterator;
66616662
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
6663+
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
66626664
}
66636665

66646666
public final class io/sentry/transport/NoOpTransport : io/sentry/transport/ITransport {

sentry/src/main/java/io/sentry/cache/EnvelopeCache.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public EnvelopeCache(
9393
previousSessionLatch = new CountDownLatch(1);
9494
}
9595

96+
@SuppressWarnings("deprecation")
9697
@Override
9798
public void store(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
9899
Objects.requireNonNull(envelope, "Envelope is required.");

sentry/src/main/java/io/sentry/cache/IEnvelopeCache.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66

77
public interface IEnvelopeCache extends Iterable<SentryEnvelope> {
88

9+
@Deprecated
910
void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint);
1011

12+
default boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
13+
store(envelope, hint);
14+
return true;
15+
}
16+
17+
@Deprecated
1118
default void store(@NotNull SentryEnvelope envelope) {
12-
store(envelope, new Hint());
19+
storeEnvelope(envelope, new Hint());
1320
}
1421

1522
void discard(@NotNull SentryEnvelope envelope);

sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private static QueuedThreadPoolExecutor initExecutor(
139139
final EnvelopeSender envelopeSender = (EnvelopeSender) r;
140140

141141
if (!HintUtils.hasType(envelopeSender.hint, Cached.class)) {
142-
envelopeCache.store(envelopeSender.envelope, envelopeSender.hint);
142+
envelopeCache.storeEnvelope(envelopeSender.envelope, envelopeSender.hint);
143143
}
144144

145145
markHintWhenSendingFailed(envelopeSender.hint, true);
@@ -271,7 +271,7 @@ public void run() {
271271
TransportResult result = this.failedResult;
272272

273273
envelope.getHeader().setSentAt(null);
274-
envelopeCache.store(envelope, hint);
274+
boolean cached = envelopeCache.storeEnvelope(envelope, hint);
275275

276276
HintUtils.runIfHasType(
277277
hint,
@@ -311,14 +311,17 @@ public void run() {
311311

312312
// ignore e.g. 429 as we're not the ones actively dropping
313313
if (result.getResponseCode() >= 400 && result.getResponseCode() != 429) {
314-
HintUtils.runIfDoesNotHaveType(
315-
hint,
316-
Retryable.class,
317-
(hint) -> {
318-
options
319-
.getClientReportRecorder()
320-
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
321-
});
314+
if (!cached) {
315+
HintUtils.runIfDoesNotHaveType(
316+
hint,
317+
Retryable.class,
318+
(hint) -> {
319+
options
320+
.getClientReportRecorder()
321+
.recordLostEnvelope(
322+
DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
323+
});
324+
}
322325
}
323326

324327
throw new IllegalStateException(message);
@@ -332,10 +335,12 @@ public void run() {
332335
retryable.setRetry(true);
333336
},
334337
(hint, clazz) -> {
335-
LogUtils.logNotInstanceOf(clazz, hint, options.getLogger());
336-
options
337-
.getClientReportRecorder()
338-
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
338+
if (!cached) {
339+
LogUtils.logNotInstanceOf(clazz, hint, options.getLogger());
340+
options
341+
.getClientReportRecorder()
342+
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
343+
}
339344
});
340345
throw new IllegalStateException("Sending the event failed.", e);
341346
}
@@ -348,10 +353,12 @@ public void run() {
348353
retryable.setRetry(true);
349354
},
350355
(hint, clazz) -> {
351-
LogUtils.logNotInstanceOf(clazz, hint, options.getLogger());
352-
options
353-
.getClientReportRecorder()
354-
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelope);
356+
if (!cached) {
357+
LogUtils.logNotInstanceOf(clazz, hint, options.getLogger());
358+
options
359+
.getClientReportRecorder()
360+
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelope);
361+
}
355362
});
356363
}
357364
return result;

sentry/src/main/java/io/sentry/transport/NoOpEnvelopeCache.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ public static NoOpEnvelopeCache getInstance() {
1414
return instance;
1515
}
1616

17+
@SuppressWarnings("deprecation")
1718
@Override
1819
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {}
1920

21+
@Override
22+
public boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
23+
return false;
24+
}
25+
2026
@Override
2127
public void discard(@NotNull SentryEnvelope envelope) {}
2228

0 commit comments

Comments
 (0)