Skip to content

Commit

Permalink
Merge pull request #807 from ably/feature/fix-npe-ably-completion-lis…
Browse files Browse the repository at this point in the history
…tener

Fix NPE from Ably CompletionListeners
  • Loading branch information
KacperKluka authored Nov 17, 2022
2 parents b7d4863 + f6fdc23 commit 0fecfcc
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions common/src/main/java/com/ably/tracking/common/Ably.kt
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,11 @@ constructor(
continuation.resume(Unit)
}

override fun onError(reason: ErrorInfo) {
continuation.resumeWithException(reason.toTrackingException())
override fun onError(reason: ErrorInfo?) {
continuation.resumeWithException(
reason?.toTrackingException()
?: ConnectionException(ErrorInformation("Unknown error when leaving presence ${channel.name}"))
)
}
}
)
Expand Down Expand Up @@ -545,8 +548,11 @@ constructor(
continuation.resume(Unit)
}

override fun onError(reason: ErrorInfo) {
continuation.resumeWithException(reason.toTrackingException())
override fun onError(reason: ErrorInfo?) {
continuation.resumeWithException(
reason?.toTrackingException()
?: ConnectionException(ErrorInformation("Unknown error when sending message ${channel.name}"))
)
}
}
)
Expand Down Expand Up @@ -720,8 +726,11 @@ constructor(
continuation.resume(Unit)
}

override fun onError(reason: ErrorInfo) {
continuation.resumeWithException(reason.toTrackingException())
override fun onError(reason: ErrorInfo?) {
continuation.resumeWithException(
reason?.toTrackingException()
?: ConnectionException(ErrorInformation("Unknown error when updating presence ${channel.name}"))
)
}
}
)
Expand Down Expand Up @@ -870,8 +879,11 @@ constructor(
continuation.resume(Unit)
}

override fun onError(reason: ErrorInfo) {
continuation.resumeWithException(reason.toTrackingException())
override fun onError(reason: ErrorInfo?) {
continuation.resumeWithException(
reason?.toTrackingException()
?: ConnectionException(ErrorInformation("Unknown error when entering presence $name"))
)
}
}
)
Expand All @@ -893,8 +905,11 @@ constructor(
continuation.resume(Unit)
}

override fun onError(reason: ErrorInfo) {
continuation.resumeWithException(reason.toTrackingException())
override fun onError(reason: ErrorInfo?) {
continuation.resumeWithException(
reason?.toTrackingException()
?: ConnectionException(ErrorInformation("Unknown error when attaching channel $name"))
)
}
})
} catch (ablyException: AblyException) {
Expand Down

0 comments on commit 0fecfcc

Please sign in to comment.