Не подтверждена Коммит fe40564b создал по автору Leonid Stashevsky's avatar Leonid Stashevsky Зафиксировано автором GitHub
Просмотр файлов

Drop flaky test and update some dependencies (#4193)



* Drop flaky test

* fix(deps): update dependency org.mockito:mockito-core to v5 (#3937)

* chore: fix some comments (#4179)

Signed-off-by: default avatarriskrose <riskrock@qq.com>

* fix(deps): update dependency org.mockito:mockito-core to v5

---------

Signed-off-by: default avatarriskrose <riskrock@qq.com>
Co-authored-by: default avatarriskrose <riskrock@qq.com>
Co-authored-by: default avatarrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency org.webjars:webjars-locator-core to v0.59 (#3816)

* chore: fix some comments (#4179)

Signed-off-by: default avatarriskrose <riskrock@qq.com>

* fix(deps): update dependency org.webjars:webjars-locator-core to v0.59

---------

Signed-off-by: default avatarriskrose <riskrock@qq.com>
Co-authored-by: default avatarriskrose <riskrock@qq.com>
Co-authored-by: default avatarrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update jquery webjar to 3.7.1

* Revert wasm type nullability

* Replace CookiesTest.testWithLeadingDot with unit test

* Cleanup deprecations

* Fix expect-actual for ConnectTimeoutException

* Update API dump

* Fix websocket exception type

* Prevent dispatcher from breaking with exception

---------

Signed-off-by: default avatarriskrose <riskrock@qq.com>
Co-authored-by: default avatarrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: default avatarriskrose <riskrock@qq.com>
владелец 17469bb1
......@@ -24,6 +24,7 @@ kotlin.incremental.js.klib=false
kotlin.incremental.multiplatform=false
kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.native.ignoreIncorrectDependencies=true
kotlin.apple.xcodeCompatibility.nowarn=true
#kotlinx.atomicfu.enableJvmIrTransformation=true
#kotlinx.atomicfu.enableNativeIrTransformation=true
......
......@@ -51,8 +51,8 @@ freemarker-version = "2.3.33"
pebble-version = "3.2.2"
velocity-version = "2.3"
velocity-tools-version = "3.1"
webjars-locator-version = "0.53"
webjars-jquery-version = "3.6.4"
webjars-locator-version = "0.59"
webjars-jquery-version = "3.7.1"
thymeleaf-version = "3.1.2.RELEASE"
javax-servlet-version = "4.0.1"
jakarta-servlet-version = "5.0.0"
......
......@@ -221,10 +221,9 @@ public final class io/ktor/client/network/sockets/ConnectTimeoutException : java
public fun getCause ()Ljava/lang/Throwable;
}
public final class io/ktor/client/network/sockets/SocketTimeoutException : java/net/SocketTimeoutException {
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getCause ()Ljava/lang/Throwable;
public final class io/ktor/client/network/sockets/TimeoutExceptionsKt {
public static final fun SocketTimeoutException (Ljava/lang/String;Ljava/lang/Throwable;)Ljava/net/SocketTimeoutException;
public static synthetic fun SocketTimeoutException$default (Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)Ljava/net/SocketTimeoutException;
}
public final class io/ktor/client/plugins/BodyProgressKt {
......@@ -295,11 +294,8 @@ public final class io/ktor/client/plugins/DoubleReceivePluginKt {
public final class io/ktor/client/plugins/HttpCallValidatorConfig {
public fun <init> ()V
public final fun getExpectSuccess ()Z
public final fun handleResponseException (Lkotlin/jvm/functions/Function2;)V
public final fun handleResponseException (Lkotlin/jvm/functions/Function3;)V
public final fun handleResponseExceptionWithRequest (Lkotlin/jvm/functions/Function3;)V
public final fun setExpectSuccess (Z)V
public final fun validateResponse (Lkotlin/jvm/functions/Function2;)V
}
......@@ -473,8 +469,8 @@ public final class io/ktor/client/plugins/HttpTimeoutKt {
public static final fun ConnectTimeoutException (Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Throwable;)Lio/ktor/client/network/sockets/ConnectTimeoutException;
public static synthetic fun ConnectTimeoutException$default (Lio/ktor/client/request/HttpRequestData;Ljava/lang/Throwable;ILjava/lang/Object;)Lio/ktor/client/network/sockets/ConnectTimeoutException;
public static synthetic fun ConnectTimeoutException$default (Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Throwable;ILjava/lang/Object;)Lio/ktor/client/network/sockets/ConnectTimeoutException;
public static final fun SocketTimeoutException (Lio/ktor/client/request/HttpRequestData;Ljava/lang/Throwable;)Lio/ktor/client/network/sockets/SocketTimeoutException;
public static synthetic fun SocketTimeoutException$default (Lio/ktor/client/request/HttpRequestData;Ljava/lang/Throwable;ILjava/lang/Object;)Lio/ktor/client/network/sockets/SocketTimeoutException;
public static final fun SocketTimeoutException (Lio/ktor/client/request/HttpRequestData;Ljava/lang/Throwable;)Ljava/net/SocketTimeoutException;
public static synthetic fun SocketTimeoutException$default (Lio/ktor/client/request/HttpRequestData;Ljava/lang/Throwable;ILjava/lang/Object;)Ljava/net/SocketTimeoutException;
public static final fun convertLongTimeoutToIntWithInfiniteAsZero (J)I
public static final fun convertLongTimeoutToLongWithInfiniteAsZero (J)J
public static final fun getHttpTimeout ()Lio/ktor/client/plugins/api/ClientPlugin;
......
......@@ -4,7 +4,6 @@
package io.ktor.client.network.sockets
import io.ktor.utils.io.errors.*
import kotlinx.io.IOException
/**
......@@ -12,7 +11,11 @@ import kotlinx.io.IOException
*/
public expect class ConnectTimeoutException(message: String, cause: Throwable? = null) : IOException
public expect open class InterruptedIOException : IOException
/**
* This exception is thrown in case socket timeout (read or write) exceeded.
*/
public expect class SocketTimeoutException(message: String, cause: Throwable? = null) : IOException
public expect class SocketTimeoutException : InterruptedIOException
public expect fun SocketTimeoutException(message: String, cause: Throwable? = null): SocketTimeoutException
......@@ -30,24 +30,7 @@ public class HttpCallValidatorConfig {
/**
* Terminate [HttpClient.receivePipeline] if status code is not successful (>=300).
*/
@Deprecated(
"This property is ignored. Please use `expectSuccess` property in HttpClientConfig. " +
"This is going to become internal."
)
public var expectSuccess: Boolean = true
/**
* Add [CallExceptionHandler].
* Last added handler executes first.
*/
@Deprecated(
"Consider using the callback with request parameter",
level = DeprecationLevel.ERROR
)
public fun handleResponseException(block: CallExceptionHandler) {
responseExceptionHandlers += ExceptionHandlerWrapper(block)
}
internal var expectSuccess: Boolean = true
/**
* Add [CallRequestExceptionHandler].
......
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.client.network.sockets
import io.ktor.client.request.*
import io.ktor.utils.io.*
import io.ktor.utils.io.errors.*
import kotlinx.io.IOException
/**
......@@ -17,10 +14,17 @@ public actual class ConnectTimeoutException actual constructor(
cause: Throwable?
) : IOException(message, cause)
public actual open class InterruptedIOException : IOException()
/**
* This exception is thrown in case socket timeout (read or write) exceeded.
*/
public actual class SocketTimeoutException actual constructor(
message: String,
cause: Throwable?
) : IOException(message, cause)
public actual class SocketTimeoutException internal constructor(
override val message: String?,
override val cause: Throwable?,
unit: Unit
) : InterruptedIOException()
public actual fun SocketTimeoutException(message: String, cause: Throwable?): SocketTimeoutException {
return SocketTimeoutException(message, cause, Unit)
}
......@@ -15,11 +15,12 @@ public actual class ConnectTimeoutException actual constructor(
override val cause: Throwable?
) : ConnectException(message)
internal actual typealias InterruptedIOException = java.io.InterruptedIOException
/**
* This exception is thrown in case socket timeout (read or write) exceeded.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual class SocketTimeoutException actual constructor(
message: String,
override val cause: Throwable?
) : java.net.SocketTimeoutException(message)
public actual typealias SocketTimeoutException = java.net.SocketTimeoutException
public actual fun SocketTimeoutException(message: String, cause: Throwable?): SocketTimeoutException =
SocketTimeoutException(message).apply { initCause(cause) }
......@@ -4,9 +4,6 @@
package io.ktor.client.network.sockets
import io.ktor.client.request.*
import io.ktor.utils.io.*
import io.ktor.utils.io.errors.*
import kotlinx.io.IOException
/**
......@@ -17,10 +14,17 @@ public actual class ConnectTimeoutException actual constructor(
cause: Throwable?
) : IOException(message, cause)
public actual open class InterruptedIOException : IOException()
/**
* This exception is thrown in case socket timeout (read or write) exceeded.
*/
public actual class SocketTimeoutException actual constructor(
message: String,
cause: Throwable?
) : IOException(message, cause)
public actual class SocketTimeoutException internal constructor(
override val message: String?,
override val cause: Throwable?,
unit: Unit
) : InterruptedIOException()
public actual fun SocketTimeoutException(message: String, cause: Throwable?): SocketTimeoutException {
return SocketTimeoutException(message, cause, Unit)
}
......@@ -14,13 +14,12 @@ import org.khronos.webgl.*
import org.w3c.dom.*
import kotlin.coroutines.*
private fun tryGetEventDataAsString(data: JsAny): String =
private fun tryGetEventDataAsString(data: JsAny): String? =
js("typeof(data) === 'string' ? data : null")
private fun tryGetEventDataAsArrayBuffer(data: JsAny): ArrayBuffer =
private fun tryGetEventDataAsArrayBuffer(data: JsAny): ArrayBuffer? =
js("data instanceof ArrayBuffer ? data : null")
@Suppress("CAST_NEVER_SUCCEEDS")
internal class JsWebSocketSession(
override val coroutineContext: CoroutineContext,
private val websocket: WebSocket
......
......@@ -31,7 +31,7 @@ kotlin {
dependencies {
implementation(project(":ktor-client:ktor-client-cio"))
implementation(kotlin("test-junit5"))
implementation("org.mockito:mockito-core:3.12.4")
implementation("org.mockito:mockito-core:5.12.0")
}
}
}
......
......@@ -29,14 +29,12 @@ class HttpResponseValidatorTest {
addHandler { respondOk() }
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
firstHandler++
assertTrue(cause is CallValidatorTestException)
}
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
secondHandler++
assertTrue(cause is CallValidatorTestException)
}
......@@ -80,8 +78,7 @@ class HttpResponseValidatorTest {
addHandler { throw CallValidatorTestException() }
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
assertTrue(cause is CallValidatorTestException)
firstHandler++
}
......@@ -110,8 +107,7 @@ class HttpResponseValidatorTest {
addHandler { respondOk() }
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
assertTrue(cause is CallValidatorTestException)
handleTriggered = true
}
......@@ -135,8 +131,7 @@ class HttpResponseValidatorTest {
addHandler { respondOk() }
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
assertTrue(cause is CallValidatorTestException)
handleTriggered = true
}
......@@ -160,16 +155,14 @@ class HttpResponseValidatorTest {
addHandler { respondOk() }
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
firstHandler++
assertTrue(cause is CallValidatorTestException)
}
}
HttpResponseValidator {
@Suppress("DEPRECATION_ERROR")
handleResponseException { cause ->
handleResponseException { cause, _ ->
secondHandler++
assertTrue(cause is CallValidatorTestException)
}
......
......@@ -20,50 +20,6 @@ import kotlinx.coroutines.flow.*
import kotlin.test.*
class LoggingMockedTests {
@Test
fun testLogRequestWithException() = testWithEngine(MockEngine) {
val testLogger = TestLogger(
"REQUEST: ${URLBuilder.origin}",
"METHOD: HttpMethod(value=GET)",
"COMMON HEADERS",
"-> Accept: */*",
"-> Accept-Charset: UTF-8",
"CONTENT HEADERS",
"-> Content-Length: 0",
"BODY Content-Type: null",
"BODY START",
"",
"BODY END",
"REQUEST ${URLBuilder.origin} failed with exception: CustomError[BAD REQUEST]"
)
config {
engine {
addHandler {
throw CustomError("BAD REQUEST")
}
}
install(Logging) {
level = LogLevel.ALL
logger = testLogger
}
}
test { client ->
var failed = false
try {
client.get { url(port = DEFAULT_PORT) }
} catch (_: Throwable) {
failed = true
}
assertTrue(failed, "Exception is missing.")
}
after {
testLogger.verify()
}
}
@Test
fun testLogResponseWithException() = testWithEngine(MockEngine) {
......
......@@ -14,7 +14,7 @@ import io.ktor.client.tests.utils.*
import io.ktor.http.*
import kotlin.test.*
class CookiesTest : ClientLoader() {
class CookiesIntegrationTests : ClientLoader() {
private val hostname = "http://127.0.0.1/cookies"
private val TEST_HOST = "$TEST_SERVER/cookies"
private val domain = "127.0.0.1"
......@@ -116,24 +116,6 @@ class CookiesTest : ClientLoader() {
assertEquals("OK", client.get("$TEST_HOST/withPath/something").body())
}
}
@Test
fun testWithLeadingDot() = clientTests(listOf("Js", "Darwin", "DarwinLegacy", "native:CIO")) {
config {
install(HttpCookies)
}
test { client ->
client.get("https://m.vk.com").body<Unit>()
assertTrue(client.cookies("https://.vk.com").isNotEmpty())
assertTrue(client.cookies("https://vk.com").isNotEmpty())
assertTrue(client.cookies("https://m.vk.com").isNotEmpty())
assertTrue(client.cookies("https://m.vk.com").isNotEmpty())
assertTrue(client.cookies("https://google.com").isEmpty())
}
}
@Test
fun caseSensitive() = clientTests(listOf("Js", "Darwin", "DarwinLegacy")) {
config {
......
......@@ -62,4 +62,30 @@ class CookiesMockTest {
client.get {}.body<String>()
}
}
@Test
fun testWithLeadingDotInDomain() = testWithEngine(MockEngine) {
config {
install(HttpCookies)
engine {
addHandler {
respond("OK", HttpStatusCode.OK, headersOf(
HttpHeaders.SetCookie, "myServer=value; Domain=.vk.com; secure"
))
}
}
}
test { client ->
client.get("https://m.vk.com").body<Unit>()
assertTrue(client.cookies("https://.vk.com").isNotEmpty())
assertTrue(client.cookies("https://vk.com").isNotEmpty())
assertTrue(client.cookies("https://m.vk.com").isNotEmpty())
assertTrue(client.cookies("https://m.vk.com").isNotEmpty())
assertTrue(client.cookies("https://google.com").isEmpty())
}
}
}
......@@ -8,6 +8,7 @@ import io.ktor.client.engine.*
import io.ktor.util.*
import io.ktor.utils.io.*
import kotlin.experimental.*
import kotlin.native.runtime.*
private class TestFailure(val name: String, val cause: Throwable) {
@OptIn(ExperimentalNativeApi::class)
......
......@@ -19,7 +19,7 @@ import kotlin.test.*
class JettyCompressionTest :
CompressionTestSuite<JettyApplicationEngine, JettyApplicationEngineBase.Configuration>(Jetty)
class JettyContentTest : ContentTestSuite<JettyApplicationEngine, JettyApplicationEngineBase.Configuration>(Jetty)
class JettyJakartaContentTest : ContentTestSuite<JettyApplicationEngine, JettyApplicationEngineBase.Configuration>(Jetty)
class JettyHttpServerCommonTest :
HttpServerCommonTestSuite<JettyApplicationEngine, JettyApplicationEngineBase.Configuration>(Jetty) {
......
......@@ -5,6 +5,7 @@
package io.ktor.server.netty
import io.ktor.util.cio.*
import io.ktor.util.logging.*
import io.netty.channel.*
import io.netty.util.concurrent.*
import io.netty.util.concurrent.Future
......@@ -13,6 +14,8 @@ import java.io.*
import java.util.concurrent.*
import kotlin.coroutines.*
private val LOG = KtorSimpleLogger("io.ktor.server.netty.CIO")
@Suppress("IMPLICIT_NOTHING_AS_TYPE_PARAMETER")
private val identityErrorHandler = { t: Throwable, c: Continuation<*> ->
c.resumeWithException(t)
......@@ -66,7 +69,13 @@ internal object NettyDispatcher : CoroutineDispatcher() {
override fun dispatch(context: CoroutineContext, block: Runnable) {
val nettyContext = context[CurrentContextKey]!!.context
nettyContext.executor().execute(block)
val result = runCatching {
nettyContext.executor().execute(block)
}
if (result.isFailure) {
LOG.error("Failed to dispatch", result.exceptionOrNull())
}
}
class CurrentContext(val context: ChannelHandlerContext) : AbstractCoroutineContextElement(CurrentContextKey)
......
......@@ -108,7 +108,7 @@ class WebjarsTest {
fun withSpecificVersion() = testApplication {
install(Webjars)
client.get("/webjars/jquery/3.6.4/jquery.js").let { response ->
client.get("/webjars/jquery/3.7.1/jquery.js").let { response ->
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(ContentType.Text.JavaScript, response.contentType()?.withoutParameters())
}
......@@ -139,11 +139,11 @@ class WebjarsTest {
install(Webjars)
install(ConditionalHeaders)
install(CachingHeaders)
client.get("/webjars/jquery/3.6.4/jquery.js").let { response ->
client.get("/webjars/jquery/3.7.1/jquery.js").let { response ->
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(ContentType.Text.JavaScript, response.contentType()?.withoutParameters())
assertNotNull(response.headers["Last-Modified"])
assertEquals("\"3.6.4\"", response.headers["Etag"])
assertEquals("\"3.7.1\"", response.headers["Etag"])
assertEquals("max-age=${90.days.inWholeSeconds}", response.headers["Cache-Control"])
}
}
......@@ -158,7 +158,7 @@ class WebjarsTest {
}
install(ConditionalHeaders)
install(CachingHeaders)
client.get("/webjars/jquery/3.6.4/jquery.js").let { response ->
client.get("/webjars/jquery/3.7.1/jquery.js").let { response ->
assertEquals(HttpStatusCode.OK, response.status)
assertEquals(ContentType.Text.JavaScript, response.contentType()?.withoutParameters())
assertEquals(date.toHttpDate(), response.headers["Last-Modified"])
......@@ -183,7 +183,7 @@ class WebjarsTest {
install(pluginBeforeWebjars)
install(Webjars)
val response = client.get("/webjars/jquery/3.3.1/jquery.js")
val response = client.get("/webjars/jquery/3.7.1/jquery.js")
assertEquals(HttpStatusCode.OK, response.status)
assertEquals("Hello", response.bodyAsText())
assertNotEquals(ContentType.Text.JavaScript, response.contentType()?.withoutParameters())
......
......@@ -11,6 +11,7 @@ import io.ktor.utils.io.pool.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.*
import kotlinx.io.*
import java.nio.*
import java.nio.channels.*
import kotlin.coroutines.*
......@@ -40,7 +41,7 @@ public class WebSocketReader(
readLoop(buffer)
} catch (expected: ClosedChannelException) {
} catch (expected: CancellationException) {
} catch (io: ChannelIOException) {
} catch (io: IOException) {
queue.cancel()
} catch (cause: FrameTooBigException) {
// Bypass exception via queue to prevent cancellation and handle it on the top level.
......
public final class io/ktor/util/AttributeKey {
public synthetic fun <init> (Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun equals (Ljava/lang/Object;)Z
public final fun getName ()Ljava/lang/String;
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать