Skip to content

Commit da410bc

Browse files
ref(core): Remove deprecated IEnvelopeCache.store methods (#6468)
* ref(core): Remove deprecated IEnvelopeCache.store methods Co-Authored-By: Alexander Dinauer <alexander.dinauer@sentry.io> * changelog Co-Authored-By: Alexander Dinauer <alexander.dinauer@sentry.io> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Alexander Dinauer <alexander.dinauer@sentry.io>
1 parent d3b29ed commit da410bc

11 files changed

Lines changed: 27 additions & 54 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Android: `SentryUserFeedbackDialog`: use `SentryUserFeedbackForm` instead
2424
- Android: the `SentryUserFeedbackButton` view and composable: call `Sentry.feedback().show()` from your own button instead
2525
- Remove deprecated Hub compatibility APIs in favor of `IScopes` and `Scopes` ([#6223](https://github.com/getsentry/sentry-java/pull/6223))
26+
- Remove the deprecated `IEnvelopeCache.store(...)` methods. Custom `IEnvelopeCache` implementations must implement `storeEnvelope(envelope, hint)` instead and return whether the envelope was stored ([#6468](https://github.com/getsentry/sentry-java/pull/6468))
2627
- Remove the aggregate Sentry Logs and Metrics enable options from all configuration surfaces:
2728
- Java API: `options.getLogs().setEnabled(...)` and `options.getMetrics().setEnabled(...)`
2829
- Properties files: `logs.enabled` and `metrics.enabled`

‎sentry-android-core/api/sentry-android-core.api‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,6 @@ public final class io/sentry/android/core/cache/AndroidEnvelopeCache : io/sentry
744744
public static fun markAnrReported (Lio/sentry/SentryOptions;J)V
745745
public static fun markMemoryLimiterReported (Lio/sentry/SentryOptions;J)V
746746
public static fun markTombstoneReported (Lio/sentry/SentryOptions;J)V
747-
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
748747
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
749748
}
750749

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,8 @@ public AndroidEnvelopeCache(final @NotNull SentryAndroidOptions options) {
5656
this.currentDateProvider = currentDateProvider;
5757
}
5858

59-
@SuppressWarnings("deprecation")
60-
@Override
61-
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
62-
storeInternalAndroid(envelope, hint);
63-
}
64-
6559
@Override
6660
public boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
67-
return storeInternalAndroid(envelope, hint);
68-
}
69-
70-
private boolean storeInternalAndroid(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
7161
final boolean didStore = super.storeEnvelope(envelope, hint);
7262

7363
final SentryAndroidOptions options = (SentryAndroidOptions) this.options;

‎sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class SentryAndroidTest {
647647
private class CustomEnvelopCache : IEnvelopeCache {
648648
override fun iterator(): MutableIterator<SentryEnvelope> = TODO()
649649

650-
override fun store(envelope: SentryEnvelope, hint: Hint) = Unit
650+
override fun storeEnvelope(envelope: SentryEnvelope, hint: Hint) = true
651651

652652
override fun discard(envelope: SentryEnvelope) = Unit
653653
}

‎sentry-android-core/src/test/java/io/sentry/android/core/cache/AndroidEnvelopeCacheTest.kt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.sentry.android.core.cache
22

33
import com.google.common.truth.Truth.assertThat
44
import io.sentry.DateUtils
5+
import io.sentry.Hint
56
import io.sentry.ISerializer
67
import io.sentry.NoOpLogger
78
import io.sentry.SentryEnvelope
@@ -86,7 +87,7 @@ class AndroidEnvelopeCacheTest {
8687
fun `when no uncaught hint exists, does not write startup crash file`() {
8788
val cache = fixture.getSut(tmpDir)
8889

89-
cache.store(fixture.envelope)
90+
cache.storeEnvelope(fixture.envelope, Hint())
9091

9192
assertFalse(fixture.startupCrashMarkerFile.exists())
9293
}
@@ -151,7 +152,7 @@ class AndroidEnvelopeCacheTest {
151152
fun `when no AnrV2 hint exists, does not write last anr report file`() {
152153
val cache = fixture.getSut(tmpDir)
153154

154-
cache.store(fixture.envelope)
155+
cache.storeEnvelope(fixture.envelope, Hint())
155156

156157
assertFalse(fixture.lastReportedAnrFile.exists())
157158
}

‎sentry/api/sentry.api‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,16 +4708,13 @@ public class io/sentry/cache/EnvelopeCache : io/sentry/cache/IEnvelopeCache {
47084708
public fun iterator ()Ljava/util/Iterator;
47094709
public fun movePreviousSession (Ljava/io/File;Ljava/io/File;)V
47104710
public fun persistCurrentSession (Lio/sentry/Session;)V
4711-
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
47124711
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
47134712
public fun waitPreviousSessionFlush ()Z
47144713
}
47154714

47164715
public abstract interface class io/sentry/cache/IEnvelopeCache : java/lang/Iterable {
47174716
public abstract fun discard (Lio/sentry/SentryEnvelope;)V
4718-
public fun store (Lio/sentry/SentryEnvelope;)V
4719-
public abstract fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
4720-
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
4717+
public abstract fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
47214718
}
47224719

47234720
public final class io/sentry/cache/PersistingOptionsObserver : io/sentry/IOptionsObserver {
@@ -7482,7 +7479,6 @@ public final class io/sentry/transport/NoOpEnvelopeCache : io/sentry/cache/IEnve
74827479
public fun discard (Lio/sentry/SentryEnvelope;)V
74837480
public static fun getInstance ()Lio/sentry/transport/NoOpEnvelopeCache;
74847481
public fun iterator ()Ljava/util/Iterator;
7485-
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
74867482
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
74877483
}
74887484

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,8 @@ public EnvelopeCache(
101101
previousSessionLatch = new CountDownLatch(1);
102102
}
103103

104-
@SuppressWarnings("deprecation")
105-
@Override
106-
public void store(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
107-
storeInternal(envelope, hint);
108-
}
109-
110104
@Override
111105
public boolean storeEnvelope(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
112-
return storeInternal(envelope, hint);
113-
}
114-
115-
private boolean storeInternal(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
116106
Objects.requireNonNull(envelope, "Envelope is required.");
117107

118108
// Create the cache dir lazily on the first write so Sentry.init doesn't block on the mkdirs.
@@ -421,7 +411,7 @@ public void discard(final @NotNull SentryEnvelope envelope) {
421411
*
422412
* <p>This only computes a path and never creates the directory, so that {@link
423413
* #discard(SentryEnvelope)} doesn't resurrect a cache dir it is only deleting from. Writers go
424-
* through {@link #storeInternal}, which creates the directory up front.
414+
* through {@link #storeEnvelope}, which creates the directory up front.
425415
*
426416
* @param envelope the SentryEnvelope object
427417
* @return the file

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66

77
public interface IEnvelopeCache extends Iterable<SentryEnvelope> {
88

9-
@Deprecated
10-
void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint);
11-
12-
default boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
13-
store(envelope, hint);
14-
return true;
15-
}
16-
17-
@Deprecated
18-
default void store(@NotNull SentryEnvelope envelope) {
19-
storeEnvelope(envelope, new Hint());
20-
}
9+
/**
10+
* Stores an envelope.
11+
*
12+
* @return whether the envelope was stored
13+
*/
14+
boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint);
2115

2216
void discard(@NotNull SentryEnvelope envelope);
2317
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ public static NoOpEnvelopeCache getInstance() {
1616
return instance;
1717
}
1818

19-
@SuppressWarnings("deprecation")
20-
@Override
21-
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {}
22-
2319
@Override
2420
public boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
2521
return false;

‎sentry/src/test/java/io/sentry/SentryTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ class SentryTest {
18431843
private class CustomEnvelopCache : IEnvelopeCache {
18441844
override fun iterator(): MutableIterator<SentryEnvelope> = TODO()
18451845

1846-
override fun store(envelope: SentryEnvelope, hint: Hint) = Unit
1846+
override fun storeEnvelope(envelope: SentryEnvelope, hint: Hint) = true
18471847

18481848
override fun discard(envelope: SentryEnvelope) = Unit
18491849
}

0 commit comments

Comments
 (0)