You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 79e4583
Browse filesBrowse the repository at this point in the historyBrowse files
fix(nav3): Fail closed when the property-encoding probe can't confirm the encoder
The built-in SerialNameAndProperties mapper's compatibility probe treated only a
LinkageError from the property encoder as conclusive; any other failure was
inconclusive and property encoding proceeded anyway. An API-incompatible
kotlinx.serialization version can fail the encoder without a LinkageError (for
instance, a NullPointerException under R8), so the probe passed and the mapper
went on to record wrong arguments.
Now any failure of the encode probe disables property encoding and keeps names,
since recording wrong arguments is worse than recording none.
Copy file name to clipboardExpand all lines: sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxBackStackEntryMapper.kt
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -75,10 +75,7 @@ internal class KotlinxBackStackEntryMapper(
Copy file name to clipboardExpand all lines: sentry-android-navigation3/src/main/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxCompatibilityProbe.kt
Copy file name to clipboardExpand all lines: sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxBackStackEntryMapperProbeTest.kt
+42-27Lines changed: 42 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -132,12 +132,8 @@ class KotlinxBackStackEntryMapperProbeTest {
132
132
133
133
@Test
134
134
fun`never checks the properties encoder when properties are excluded`() {
135
-
// Neither an incompatible nor an inconclusive check is logged, as neither is run.
Copy file name to clipboardExpand all lines: sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxCompatibilityProbeTest.kt
+4-13Lines changed: 4 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -23,24 +23,15 @@ class KotlinxCompatibilityProbeTest {
23
23
assertThat(inconclusive).isEmpty()
24
24
}
25
25
26
-
//encodingLinkageError()
26
+
//encoderIncompatibility()
27
27
28
28
@Test
29
-
fun`encodingLinkageError() - returns null for a compatible kotlinx serialization version`() {
30
-
val error =KotlinxCompatibilityProbe.encodingLinkageError {}
29
+
fun`encoderIncompatibility() - returns null for a compatible kotlinx serialization version`() {
30
+
val error =KotlinxCompatibilityProbe.encoderIncompatibility()
31
31
32
32
assertThat(error).isNull()
33
33
}
34
34
35
-
@Test
36
-
fun`encodingLinkageError() - finds a compatible kotlinx serialization version conclusively`() {
37
-
val inconclusive = mutableListOf<Throwable>()
38
-
39
-
KotlinxCompatibilityProbe.encodingLinkageError { inconclusive += it }
40
-
41
-
assertThat(inconclusive).isEmpty()
42
-
}
43
-
44
35
// Probe types
45
36
46
37
@Test
@@ -58,7 +49,7 @@ class KotlinxCompatibilityProbeTest {
58
49
59
50
@Test
60
51
fun`the properties encoder encodes every property of the probe's class`() {
61
-
// A probe type that failed to encode for another reason would make the check inconclusive.
52
+
// A probe type that failed to encode for another reason would make the check fail closed.
62
53
val encoded = encodeToMap(ProbeClass.serializer(), ProbeClass())
Copy file name to clipboardExpand all lines: sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/kotlinx/KotlinxMapperFixture.kt
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -77,16 +77,15 @@ internal class ShapeThrowingDetailSerializer(
77
77
78
78
/**
79
79
* A [KotlinxCompatibilityProbe] that finds the app's kotlinx.serialization version compatible
80
-
* unless [nameLookupError] or [encodingError] is set, so that mapper tests don't depend on the real
81
-
* probe. Reports the name check inconclusive with [nameLookupInconclusive], if set, and the
82
-
* encoding check inconclusive with [encodingInconclusiveError], if set. Counts the checks of the
83
-
* properties encoder in [encodingChecks].
80
+
* unless [nameLookupError] or [encoderError] is set, so that mapper tests don't depend on the real
81
+
* probe. Reports the name check inconclusive with [nameLookupInconclusive], if set. Any
82
+
* [encoderError], whether a [LinkageError] or not, makes the properties encoder unusable and
83
+
* disables property encoding. Counts the checks of the properties encoder in [encodingChecks].
0 commit comments