Skip to content

Commit

Permalink
fix false-positive warning log
Browse files Browse the repository at this point in the history
  • Loading branch information
lepicekmichal committed May 8, 2024
1 parent 999b998 commit 04b3d0c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RELEASE_SIGNING_ENABLED=true

GROUP=eu.lepicekmichal.signalrkore
POM_ARTIFACT_ID=signalrkore
VERSION_NAME=0.7.1
VERSION_NAME=0.8.0

POM_NAME=SignalR Kore
POM_DESCRIPTION=Connect to SignalR Core server with library written in Kotlin and coroutines.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ abstract class HubCommunicationLink(private val json: Json) : HubCommunication()
collectInScope(scope) { message ->
when (message) {
is HubMessage.Invocation.NonBlocking -> {
callback(message)
try {
callback(message)
} catch (ex: Exception) {
logger.log(
severity = Logger.Severity.ERROR,
message = "Getting result for non-blocking invocation of '${message.target}' method has thrown an exception",
cause = ex,
)
}
if (resultType != Unit::class) {
// todo should I also print the actual result inside message?
logger.log(
Expand Down Expand Up @@ -240,32 +248,33 @@ abstract class HubCommunicationLink(private val json: Json) : HubCommunication()
if (hasResult && resultProviderRegistry.contains(target)) {
throw IllegalStateException("There can be only one function for returning result on blocking invocation (method: $target)")
}

return receivedInvocations
.run {
if (!hasResult) {
this.onEach {
if (it is HubMessage.Invocation.Blocking) {
logger.log(
severity = Logger.Severity.WARNING,
message = "There is no result provider for ${it.target} despite server expecting it.",
cause = null,
)
complete(
HubMessage.Completion.Error(
invocationId = it.invocationId,
error = "Client did not provide a result."
),
)
}
if (!hasResult) this
else this
.onSubscription { resultProviderRegistry.add(target) }
.onCompletion { resultProviderRegistry.remove(target) }
}
.filter { it.target == target }
.run {
if (hasResult) this
else this.onEach {
if (it is HubMessage.Invocation.Blocking) {
logger.log(
severity = Logger.Severity.WARNING,
message = "There is no result provider for ${it.target} despite server expecting it.",
cause = null,
)

complete(
HubMessage.Completion.Error(
invocationId = it.invocationId,
error = "Client did not provide a result."
),
)
}
} else {
this
.onSubscription { resultProviderRegistry.add(target) }
.onCompletion { resultProviderRegistry.remove(target) }
}
}
.filter { it.target == target }
.onEach { logger.log(Logger.Severity.INFO, "Received invocation: $it", null) }
}
}

0 comments on commit 04b3d0c

Please sign in to comment.