From 3961edc540503cd9cab79ffb52519cb2dc159ec5 Mon Sep 17 00:00:00 2001 From: Brian Gambrell Date: Fri, 6 Sep 2024 15:21:36 -0400 Subject: [PATCH] Update NavKey.kt to handle null id Uses java.util.Objects.hashCode() to protect the NavKey.hashCode function from throwing errors when id is null. Id is never supposed to be null, but we keep getting crashing errors in our app in prod that we can't reproduce. --- .../main/kotlin/com/bumble/appyx/core/navigation/NavKey.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/core/src/main/kotlin/com/bumble/appyx/core/navigation/NavKey.kt b/libraries/core/src/main/kotlin/com/bumble/appyx/core/navigation/NavKey.kt index 138a6c5ff..25b418bff 100644 --- a/libraries/core/src/main/kotlin/com/bumble/appyx/core/navigation/NavKey.kt +++ b/libraries/core/src/main/kotlin/com/bumble/appyx/core/navigation/NavKey.kt @@ -4,6 +4,7 @@ import android.os.Parcelable import androidx.compose.runtime.Immutable import kotlinx.parcelize.Parcelize import kotlinx.parcelize.RawValue +import java.util.Objects import java.util.UUID @Parcelize @@ -31,8 +32,8 @@ class NavKey private constructor( } override fun hashCode(): Int { - var result = navTarget?.hashCode() ?: 0 - result = 31 * result + id.hashCode() + var result = Objects.hashCode(navTarget) + result = 31 * result + Objects.hashCode(id) return result }