Skip to content

Commit

Permalink
Use send rather than trySend
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Melchior committed Nov 29, 2023
1 parent ff0f37d commit c6c4d62
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ internal class SubscriptionSetImpl<T : BaseRealm>(
val callback = SubscriptionSetCallback { state ->
when (state) {
CoreSubscriptionSetState.RLM_SYNC_SUBSCRIPTION_COMPLETE -> {
channel.trySend(true)
channel.send(true)
}
CoreSubscriptionSetState.RLM_SYNC_SUBSCRIPTION_ERROR -> {
channel.trySend(false)
channel.send(false)
}
else -> {
// Ignore all other states, wait for either complete or error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class VersionTrackingTests {
runBlocking {
val deferred = async {
realm.asFlow().collect {
realmUpdates.trySend(Unit)
realmUpdates.send(Unit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {
results
.asFlow()
.collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {
results
.asFlow()
.collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -179,7 +179,7 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {
val c = Channel<ResultsChange<Sample>>(capacity = 5)
val collection = async {
target.objectBacklinks.asFlow().collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -239,12 +239,12 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {

val observer1 = async {
results.asFlow().collect {
c1.trySend(it)
c1.send(it)
}
}
val observer2 = async {
results.asFlow().collect {
c2.trySend(it)
c2.send(it)
}
}

Expand Down Expand Up @@ -289,10 +289,10 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {
results
.asFlow()
.onCompletion {
c.trySend(null)
c.send(null)
}
.collect {
c.trySend(it)
c.send(it)
}
}

Expand All @@ -301,10 +301,10 @@ class BacklinksNotificationsTests : RealmEntityNotificationTests {
.query("TRUEPREDICATE")
.asFlow()
.onCompletion {
sc.trySend(null)
sc.send(null)
}
.collect {
sc.trySend(it)
sc.send(it)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ class RealmDictionaryNotificationsTests : RealmEntityNotificationTests {
container.nullableObjectDictionaryField
.asFlow()
.collect { mapChange ->
channel1.trySend(mapChange)
channel1.send(mapChange)
}
}
val observer2 = async {
container.nullableObjectDictionaryField
.asFlow()
.collect { mapChange ->
channel2.trySend(mapChange)
channel2.send(mapChange)
}
}

Expand Down Expand Up @@ -417,7 +417,7 @@ class RealmDictionaryNotificationsTests : RealmEntityNotificationTests {
container.nullableObjectDictionaryField
.asFlow()
.collect { mapChange ->
channel.trySend(mapChange)
channel.send(mapChange)
}
fail("Flow should not be canceled.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ class RealmListNotificationsTests : RealmEntityNotificationTests {
container.objectListField
.asFlow()
.collect { flowList ->
channel1.trySend(flowList)
channel1.send(flowList)
}
}
val observer2 = async {
container.objectListField
.asFlow()
.collect { flowList ->
channel2.trySend(flowList)
channel2.send(flowList)
}
}

Expand Down Expand Up @@ -457,7 +457,7 @@ class RealmListNotificationsTests : RealmEntityNotificationTests {
container.objectListField
.asFlow()
.collect { flowList ->
channel.trySend(flowList)
channel.send(flowList)
}
fail("Flow should not be canceled.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RealmObjectNotificationsTests : RealmEntityNotificationTests {
}
val observer = async {
obj.asFlow().collect {
c.trySend(it)
c.send(it)
}
}

Expand All @@ -106,7 +106,7 @@ class RealmObjectNotificationsTests : RealmEntityNotificationTests {
}
val observer = async {
obj.asFlow().collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -158,12 +158,12 @@ class RealmObjectNotificationsTests : RealmEntityNotificationTests {
val c2 = TestChannel<ObjectChange<Sample>>()
val observer1 = async {
obj.asFlow().collect {
c1.trySend(it)
c1.send(it)
}
}
val observer2 = async {
obj.asFlow().collect {
c2.trySend(it)
c2.send(it)
}
}
// First event should be the initial value
Expand Down Expand Up @@ -288,7 +288,7 @@ class RealmObjectNotificationsTests : RealmEntityNotificationTests {
}
val observer = async {
obj.asFlow().collect {
c.trySend(it)
c.send(it)
}
fail("Flow should not be canceled.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RealmResultsNotificationsTests : FlowableTests {
realm.query<Sample>()
.asFlow()
.collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ class RealmResultsNotificationsTests : FlowableTests {
.sort("stringField")
.asFlow()
.collect {
c.trySend(it)
c.send(it)
}
}

Expand Down Expand Up @@ -286,14 +286,14 @@ class RealmResultsNotificationsTests : FlowableTests {
realm.query<Sample>()
.asFlow()
.collect {
c1.trySend(it)
c1.send(it)
}
}
val observer2 = async {
realm.query<Sample>()
.asFlow()
.collect {
c2.trySend(it)
c2.send(it)
}
}

Expand Down Expand Up @@ -334,10 +334,10 @@ class RealmResultsNotificationsTests : FlowableTests {
.asFlow()
.collect {
when (counter.incrementAndGet()) {
1 -> c.trySend(it.list.size)
1 -> c.send(it.list.size)
2 -> {
realm.close()
c.trySend(-1)
c.send(-1)
println("realm closed")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ class RealmSetNotificationsTests : RealmEntityNotificationTests {
container.objectSetField
.asFlow()
.collect { flowSet ->
channel1.trySend(flowSet)
channel1.send(flowSet)
}
}
val observer2 = async {
container.objectSetField
.asFlow()
.collect { flowSet ->
channel2.trySend(flowSet)
channel2.send(flowSet)
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ class RealmSetNotificationsTests : RealmEntityNotificationTests {
container.objectSetField
.asFlow()
.collect { flowSet ->
channel.trySend(flowSet)
channel.send(flowSet)
}
fail("Flow should not be canceled.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class AppConfigurationTests {
"$AUTH_HEADER_NAME: "
)
) {
channel.trySend(true)
channel.send(true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ class HttpLogObfuscatorTests {
) {
message?.also {
if (it.contains(""""password":"***"""")) {
channel.trySend(Operation.OBFUSCATED_PASSWORD)
channel.send(Operation.OBFUSCATED_PASSWORD)
} else if (it.contains(""""access_token":"***","refresh_token":"***"""")) {
channel.trySend(Operation.OBFUSCATED_ACCESS_AND_REFRESH_TOKENS)
channel.send(Operation.OBFUSCATED_ACCESS_AND_REFRESH_TOKENS)
} else if (it.contains(""""key":"***"""")) {
channel.trySend(Operation.OBFUSCATED_API_KEY)
channel.send(Operation.OBFUSCATED_API_KEY)
} else if (it.contains(""""id_token":"***"""")) {
channel.trySend(Operation.OBFUSCATED_APPLE_OR_GOOGLE_ID_TOKEN)
channel.send(Operation.OBFUSCATED_APPLE_OR_GOOGLE_ID_TOKEN)
} else if (it.contains(""""accessToken":"***"""")) {
channel.trySend(Operation.OBFUSCATED_FACEBOOK)
channel.send(Operation.OBFUSCATED_FACEBOOK)
} else if (it.contains(""""authCode":"***"""")) {
channel.trySend(Operation.OBFUSCATED_GOOGLE_AUTH_CODE)
channel.send(Operation.OBFUSCATED_GOOGLE_AUTH_CODE)
} else if (it.contains(""""token":"***"""")) {
channel.trySend(Operation.OBFUSCATED_JWT)
channel.send(Operation.OBFUSCATED_JWT)
} else if (
it.contains(""""arguments":[***]""") ||
it.contains("BODY START\n***\nBODY END")
) {
channel.trySend(Operation.OBFUSCATED_CUSTOM_FUNCTION)
channel.send(Operation.OBFUSCATED_CUSTOM_FUNCTION)
} else if (it.contains(""""password":"$password"""")) {
channel.cancel(CancellationException("Password was not obfuscated: $message"))
} else if (it.contains(""""(("access_token"):(".+?")),(("refresh_token"):(".+?"))""".toRegex())) {
Expand Down
Loading

0 comments on commit c6c4d62

Please sign in to comment.