Skip to content

Commit

Permalink
[ML4SE-372] Added timeout for the sendFile function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Feb 12, 2024
1 parent af4e909 commit 142e423
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package org.jetbrains.research.tasktracker.requests
import com.intellij.openapi.diagnostic.Logger
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.*
import io.ktor.client.request.forms.*
import io.ktor.client.statement.*
import io.ktor.http.*
import org.apache.http.client.utils.URIBuilder
import org.jetbrains.research.tasktracker.config.MainTaskTrackerConfig.Companion.getRoute
Expand All @@ -15,6 +15,7 @@ object FileRequests {

private val client = HttpClient(CIO)
private val logger: Logger = Logger.getInstance(FileRequests::class.java)
private const val TIMEOUT: Long = 15_000 // 15 seconds

@Suppress("TooGenericExceptionCaught")
suspend fun sendFile(file: File, logFileType: String): Boolean {
Expand All @@ -35,6 +36,11 @@ object FileRequests {
)
}
)
},
block = {
timeout {
requestTimeoutMillis = TIMEOUT
}
}
)
return response.status.isSuccess()
Expand Down

0 comments on commit 142e423

Please sign in to comment.