Skip to content

Commit

Permalink
[TH2-4351] Check status when submitting events
Browse files Browse the repository at this point in the history
  • Loading branch information
OptimumCode committed Feb 2, 2023
1 parent 62277d8 commit 15bb5ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package com.exactpro.th2.check1
import io.reactivex.observers.DisposableObserver
import mu.KotlinLogging
import org.slf4j.Logger
import org.slf4j.LoggerFactory

abstract class AbstractSessionObserver<T> : DisposableObserver<T>() {
override fun onComplete() {
Expand All @@ -27,6 +28,6 @@ abstract class AbstractSessionObserver<T> : DisposableObserver<T>() {

companion object {
@JvmField
val LOGGER: Logger = KotlinLogging.logger { }
val LOGGER: Logger = LoggerFactory.getLogger(AbstractSessionObserver::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,14 @@ abstract class AbstractCheckTask(

private fun taskFinished() {
try {
val currentState = taskState.get()
val currentState = taskState.updateAndGet {
when (it) {
// When we complete because of the stream completion the unsubscribe method might be called before the complete method
// Because of that we need to check the status and use the completion status if we are still in BEGIN state
State.BEGIN -> streamCompletedState
else -> it
}
}
LOGGER.info("Finishes task '$description' in state ${currentState.name}")
if (currentState.callOnTimeoutCallback) {
callOnTimeoutCallback()
Expand Down

0 comments on commit 15bb5ee

Please sign in to comment.