From 152f086b8dd2d10f0aec29b50ca67db650860062 Mon Sep 17 00:00:00 2001 From: Osip Fatkullin Date: Fri, 27 Dec 2024 16:07:06 +0100 Subject: [PATCH] Fix warnings in test-server --- .../src/main/kotlin/test/server/ClientTestServer.kt | 1 - .../src/main/kotlin/test/server/ServerUtils.kt | 4 ++-- .../main/kotlin/test/server/tests/Multithreaded.kt | 13 +++---------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt b/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt index 2b463a29f8..ed47267c59 100644 --- a/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt +++ b/ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt @@ -4,7 +4,6 @@ package test.server -import io.ktor.client.tests.utils.tests.* import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.plugins.defaultheaders.* diff --git a/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt b/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt index 8d733c90cb..de3ea90ad8 100644 --- a/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt +++ b/ktor-test-server/src/main/kotlin/test/server/ServerUtils.kt @@ -8,7 +8,7 @@ import io.ktor.http.* import io.ktor.http.content.* import io.ktor.util.* import io.ktor.utils.io.* -import io.ktor.utils.io.core.* +import kotlinx.io.readByteArray fun makeArray(size: Int): ByteArray = ByteArray(size) { it.toByte() } @@ -32,6 +32,6 @@ internal suspend fun filenameContentTypeAndContentString(provider: () -> ByteRea val disposition: ContentDisposition = ContentDisposition.parse(dispositionHeader) val filename: String = disposition.parameter("filename") ?: "" val contentType = headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) } ?: "" - val content: String = provider().readRemaining().readBytes().let { "Content of ${it.size} bytes" } + val content: String = provider().readRemaining().readByteArray().let { "Content of ${it.size} bytes" } return "$filename$contentType$content" } diff --git a/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt b/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt index 81b5fa818e..6fb574d86b 100644 --- a/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt +++ b/ktor-test-server/src/main/kotlin/test/server/tests/Multithreaded.kt @@ -2,23 +2,16 @@ * 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.tests.utils.tests +package test.server.tests import io.ktor.server.application.* -import io.ktor.server.http.content.* import io.ktor.server.response.* import io.ktor.server.routing.* -import test.server.tests.counter internal fun Application.multithreadedTest() { routing { - route("multithreaded") { - get { - call.respondText(counter.incrementAndGet().toString()) - } - static { - resource("jarfile", "String.class", "java.lang") - } + get("multithreaded") { + call.respondText(counter.incrementAndGet().toString()) } } }