Открыть боковую панель
Aurora OS
Kotlin Multiplatform
Libraries
ktor
Коммиты
8e570d46
Коммит
8e570d46
создал
Окт 24, 2019
по автору
dmitrievanthony
Зафиксировано автором
Leonid Stashevsky
Окт 28, 2019
Просмотр файлов
Fix OkHttp close method and correspondent test.
владелец
b36ea958
Изменения
2
Скрыть пробелы
Построчно
Рядом
ktor-client/ktor-client-okhttp/jvm/src/io/ktor/client/engine/okhttp/OkHttpEngine.kt
Просмотр файла @
8e570d46
...
@@ -54,7 +54,7 @@ class OkHttpEngine(
...
@@ -54,7 +54,7 @@ class OkHttpEngine(
clientTask
.
complete
()
clientTask
.
complete
()
clientTask
.
invokeOnCompletion
{
clientTask
.
invokeOnCompletion
{
launch
(
dispatcher
)
{
GlobalScope
.
launch
(
dispatcher
)
{
engine
.
dispatcher
().
executorService
().
shutdown
()
engine
.
dispatcher
().
executorService
().
shutdown
()
engine
.
connectionPool
().
evictAll
()
engine
.
connectionPool
().
evictAll
()
engine
.
cache
()
?.
close
()
engine
.
cache
()
?.
close
()
...
...
ktor-client/ktor-client-okhttp/jvm/test/io/ktor/client/engine/okhttp/OkHttpEngineTests.kt
0 → 100644
Просмотр файла @
8e570d46
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package
io.ktor.client.engine.okhttp
import
kotlinx.coroutines.*
import
okhttp3.*
import
kotlin.test.*
class
OkHttpEngineTests
{
@Test
fun
closeTest
()
{
val
okHttpClient
=
OkHttpClient
()
val
engine
=
OkHttpEngine
(
OkHttpConfig
().
apply
{
preconfigured
=
okHttpClient
})
engine
.
close
()
runBlocking
{
withTimeout
(
1000
)
{
while
(!
okHttpClient
.
dispatcher
().
executorService
().
isShutdown
)
{
yield
()
}
assertTrue
(
"OkHttp dispatcher is still working."
)
{
okHttpClient
.
dispatcher
().
executorService
().
isShutdown
}
assertEquals
(
0
,
okHttpClient
.
connectionPool
().
connectionCount
())
okHttpClient
.
cache
()
?.
let
{
assertTrue
(
"OkHttp client cache is not closed."
)
{
it
.
isClosed
}
}
}
}
}
}
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать