Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RKOTLIN-1102] Remove nullability check in SubscriptionSetImpl.waitForSynchronization #1778

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixed
* [Sync] Fatal sync exceptions are now thrown as `UnrecoverableSyncException`. (Issue [#1767](https://github.com/realm/realm-kotlin/issues/1767) [RKOTLIN-1096](https://jira.mongodb.org/browse/RKOTLIN-1096)).
* [Sync] Fix `NullPointerException` in `SubscriptionSet.waitForSynchronization`. (Issue [#1777](https://github.com/realm/realm-kotlin/issues/1777) [RKOTLIN-1102](https://jira.mongodb.org/browse/RKOTLIN-1102)).

### Compatibility
* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package io.realm.kotlin.exceptions
*/
public open class RealmException : RuntimeException {
public constructor() : super()
public constructor(message: String) : super(message)
public constructor(message: String, cause: Throwable) : super(message, cause)
public constructor(cause: Throwable) : super(cause)
public constructor(message: String?) : super(message)
public constructor(message: String?, cause: Throwable) : super(message, cause)
clementetb marked this conversation as resolved.
Show resolved Hide resolved
public constructor(cause: Throwable?) : super(cause)
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ import io.realm.kotlin.exceptions.RealmException
* @see SyncException
*/
public open class AppException internal constructor(
message: String,
message: String?,
) : RealmException(message)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import io.realm.kotlin.types.RealmAny
*
* @see io.realm.kotlin.mongodb.sync.SyncConfiguration.Builder.errorHandler
*/
public open class SyncException internal constructor(message: String) : AppException(message)
public open class SyncException internal constructor(message: String?) : AppException(message)

/**
* Thrown when something has gone wrong with Device Sync in a way that is not recoverable.
Expand Down Expand Up @@ -60,7 +60,7 @@ public class WrongSyncTypeException internal constructor(message: String) : Sync
* Thrown when the server does not support one or more of the queries defined in the
* [io.realm.kotlin.mongodb.sync.SubscriptionSet].
*/
public class BadFlexibleSyncQueryException internal constructor(message: String) :
public class BadFlexibleSyncQueryException internal constructor(message: String?) :
SyncException(message)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ internal class SubscriptionSetImpl<T : BaseRealm>(
if (result) {
return true
} else {
throw BadFlexibleSyncQueryException(errorMessage!!)
throw BadFlexibleSyncQueryException(errorMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this nullable because RealmInterop.realm_sync_subscriptionset_error_str can return null/empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like it.

}
}
else -> throw IllegalStateException("Unexpected value: $result")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class CredentialsTests {
payload = mapOf("mail" to TestHelper.randomEmail(), "id" to 0)
)

assertFailsWithMessage<AuthException>("unauthorized") {
assertFailsWithMessage<AuthException>("Authentication failed") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Weird that this has to go the other way. Was updated on the server two weeks ago and seemed pretty consistent with unauthorized throughout the server 🤔 But I guess it is ok, since it is just a test assertion 🤷

runBlocking {
app.login(credentials)
}
Expand Down
Loading