Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-6734 Upgrade Jetty to 12 #4578

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4ab1c2f
KTOR-7606 Make Closable implement AutoCloseable (#4414)
osipxd Oct 28, 2024
425f296
KTOR-7586 Improve parsing of supported media types (#4410)
anton-erofeev Oct 30, 2024
bb029fc
Version 3.1.0-SNAPSHOT
osipxd Oct 30, 2024
5e238ab
KTOR-7586 Fix MimesTest doesn't compile on JS target (#4438)
osipxd Oct 31, 2024
44a7169
KTOR-6004 Support TCP and Unix socket for wasm-js and js via NodeJS (…
whyoleg Oct 31, 2024
bf582b9
KTOR-7663 Add `bind` overload for UDPSocketBuilder (#4456)
marychatte Nov 8, 2024
9803f38
KTOR-7675 Support CIO client for wasm-js and js (#4441)
whyoleg Nov 8, 2024
06ad511
KTOR-7620 Make Url class @Serializable and JVM Serializable (#4421)
wkornewald Nov 12, 2024
b63c455
KTOR-6632 Support receiving multipart data with Ktor client (#4458)
e5l Nov 13, 2024
4ebdc6d
KTOR-7435 Add serialization for SSE (#4363)
marychatte Nov 15, 2024
c129d31
Update dependency io.micrometer:micrometer-core to v1.14.1 (#4472)
renovate[bot] Nov 18, 2024
68bbd9e
Use static libcurl build with conan (#4445)
whyoleg Nov 19, 2024
d2364e9
KTOR-7644 Make re-auth status codes configurable (#4420)
wkornewald Nov 19, 2024
2049496
KTOR-7679 Allow disabling body decoding on server (#4444)
e5l Nov 19, 2024
195836d
KTOR-7359 Implement a suspending version of EmbeddedServer.start and …
whyoleg Nov 19, 2024
5628239
KTOR-7470 receiveMultipart throw UnsupportedMediaTypeException (#4339)
stokado Nov 21, 2024
c0b9cb7
KTOR-7722 content negotiation client accept header control (#4462)
rocketraman Nov 22, 2024
94c94bd
KTOR-7893 Add favicon to Swagger UI (#4528)
marychatte Dec 5, 2024
f555d1a
KTOR-7908 Add heartbeat to SSE (#4543)
marychatte Dec 12, 2024
5f100bf
fixup! KTOR-7620 Make Url class @Serializable and JVM Serializable (#…
osipxd Dec 19, 2024
af5ae28
KTOR-6734 Upgrade Jetty to 12
bjhham Dec 23, 2024
c7fef35
KTOR-6734 Fixes for Jetty 12 upgrade
bjhham Dec 31, 2024
4829dac
fixup! KTOR-6734 Fixes for Jetty 12 upgrade
bjhham Jan 2, 2025
ebee081
fixup! KTOR-6734 Fixes for Jetty 12 upgrade
bjhham Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/test/server/tests/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ internal fun Application.authTestServer() {
val token = call.request.headers["Authorization"]
if (token.isNullOrEmpty() || token.contains("invalid")) {
call.response.header(HttpHeaders.WWWAuthenticate, "Bearer realm=\"TestServer\"")
call.respond(HttpStatusCode.Unauthorized)
val status = call.request.queryParameters["status"]?.toIntOrNull() ?: 401
call.respond(HttpStatusCode.fromValue(status))
return@get
}

Expand Down
13 changes: 13 additions & 0 deletions buildSrc/src/main/kotlin/test/server/tests/MultiPartFormData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package test.server.tests

import io.ktor.client.request.forms.*
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.server.application.*
Expand Down Expand Up @@ -34,6 +35,18 @@ internal fun Application.multiPartFormDataTest() {
call.receiveMultipart().readPart()
call.respond(HttpStatusCode.OK)
}
post("receive") {
val multipart = MultiPartFormDataContent(
formData {
append("text", "Hello, World!")
append("file", ByteArray(1024) { it.toByte() }, Headers.build {
append(HttpHeaders.ContentDisposition, """form-data; name="file"; filename="test.bin"""")
append(HttpHeaders.ContentType, ContentType.Application.OctetStream.toString())
})
}
)
call.respond(multipart)
}
}
}
}
30 changes: 29 additions & 1 deletion buildSrc/src/main/kotlin/test/server/tests/ServerSentEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,41 @@ internal fun Application.serverSentEvents() {
emit(SseEvent("Hello"))
}
)

}

get("/content-type-text-plain") {
call.response.header(HttpHeaders.ContentType, ContentType.Text.Plain.toString())
call.respond(HttpStatusCode.OK)
}

get("/person") {
val times = call.parameters["times"]?.toInt() ?: 1
call.respondSseEvents(
flow {
repeat(times) {
emit(SseEvent(data = "Name $it", event = "event $it", id = "$it"))
}
}
)
}

get("/json") {
val customer = """
{ "id": 1,
"firstName": "Jet",
"lastName": "Brains"
}""".trimIndent()
val product = """
{ "name": "Milk",
"price": "100"
}""".trimIndent()
call.respondSseEvents(
flow {
emit(SseEvent(data = customer))
emit(SseEvent(data = product))
}
)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

# sytleguide
# styleguide
kotlin.code.style=official

# config
version=3.0.3
version=3.1.0-SNAPSHOT

## Performance

Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ netty = "4.1.116.Final"
netty-tcnative = "2.0.69.Final"

jetty = "9.4.56.v20240826"
jetty-jakarta = "11.0.24"
jetty-jakarta = "12.0.16"
jetty-alpn-api = "1.1.3.v20160715"
jetty-alpn-boot = "8.1.13.v20181017"
jetty-alpn-openjdk8 = "9.4.56.v20240826"
Expand All @@ -43,7 +43,7 @@ slf4j = "2.0.16"
logback = "1.5.12"

dropwizard = "4.2.29"
micrometer = "1.13.6"
micrometer = "1.14.1"

jansi = "2.4.1"
typesafe = "1.4.3"
Expand Down Expand Up @@ -160,12 +160,12 @@ jetty-alpn-openjdk8-server = { module = "org.eclipse.jetty:jetty-alpn-openjdk8-s
jetty-alpn-openjdk8-client = { module = "org.eclipse.jetty:jetty-alpn-openjdk8-client", version.ref = "jetty-alpn-openjdk8" }

jetty-client-jakarta = { module = "org.eclipse.jetty:jetty-client", version.ref = "jetty-jakarta" }
jetty-http2-server-jakarta = { module = "org.eclipse.jetty.http2:http2-server", version.ref = "jetty-jakarta" }
jetty-http2-client-jakarta = { module = "org.eclipse.jetty.http2:http2-client", version.ref = "jetty-jakarta" }
jetty-http2-server-jakarta = { module = "org.eclipse.jetty.http2:jetty-http2-server", version.ref = "jetty-jakarta" }
jetty-http2-client-jakarta = { module = "org.eclipse.jetty.http2:jetty-http2-client", version.ref = "jetty-jakarta" }
jetty-http2-client-transport-jakarta = { module = "org.eclipse.jetty.http2:http2-http-client-transport", version.ref = "jetty-jakarta" }
jetty-server-jakarta = { module = "org.eclipse.jetty:jetty-server", version.ref = "jetty-jakarta" }
jetty-servlets-jakarta = { module = "org.eclipse.jetty:jetty-servlets", version.ref = "jetty-jakarta" }
jetty-servlet-jakarta = { module = "org.eclipse.jetty:jetty-servlet", version.ref = "jetty-jakarta" }
jetty-servlets-jakarta = { module = "org.eclipse.jetty.ee10:jetty-ee10-servlets", version.ref = "jetty-jakarta" }
jetty-servlet-jakarta = { module = "org.eclipse.jetty.ee10:jetty-ee10-servlet", version.ref = "jetty-jakarta" }
jetty-alpn-server-jakarta = { module = "org.eclipse.jetty:jetty-alpn-server", version.ref = "jetty-jakarta" }
jetty-alpn-java-server-jakarta = { module = "org.eclipse.jetty:jetty-alpn-java-server", version.ref = "jetty-jakarta" }
jetty-alpn-java-client-jakarta = { module = "org.eclipse.jetty:jetty-alpn-java-client", version.ref = "jetty-jakarta" }
Expand Down
3 changes: 3 additions & 0 deletions ktor-client/ktor-client-android/api/ktor-client-android.api
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
public final class io/ktor/client/engine/android/Android : io/ktor/client/engine/HttpClientEngineFactory {
public static final field INSTANCE Lio/ktor/client/engine/android/Android;
public fun create (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/engine/HttpClientEngine;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/ktor/client/engine/android/AndroidClientEngine : io/ktor/client/engine/HttpClientEngineBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.ktor.client.engine.*
*
* You can learn more about client engines from [Engines](https://ktor.io/docs/http-client-engines.html).
*/
public object Android : HttpClientEngineFactory<AndroidEngineConfig> {
public data object Android : HttpClientEngineFactory<AndroidEngineConfig> {
override fun create(block: AndroidEngineConfig.() -> Unit): HttpClientEngine =
AndroidClientEngine(AndroidEngineConfig().apply(block))
}
Expand Down
3 changes: 3 additions & 0 deletions ktor-client/ktor-client-apache/api/ktor-client-apache.api
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
public final class io/ktor/client/engine/apache/Apache : io/ktor/client/engine/HttpClientEngineFactory {
public static final field INSTANCE Lio/ktor/client/engine/apache/Apache;
public fun create (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/engine/HttpClientEngine;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/ktor/client/engine/apache/ApacheEngineConfig : io/ktor/client/engine/HttpClientEngineConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.ktor.client.engine.*
*
* You can learn more about client engines from [Engines](https://ktor.io/docs/http-client-engines.html).
*/
public object Apache : HttpClientEngineFactory<ApacheEngineConfig> {
public data object Apache : HttpClientEngineFactory<ApacheEngineConfig> {
override fun create(block: ApacheEngineConfig.() -> Unit): HttpClientEngine {
val config = ApacheEngineConfig().apply(block)
return ApacheEngine(config)
Expand Down
3 changes: 3 additions & 0 deletions ktor-client/ktor-client-apache5/api/ktor-client-apache5.api
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
public final class io/ktor/client/engine/apache5/Apache5 : io/ktor/client/engine/HttpClientEngineFactory {
public static final field INSTANCE Lio/ktor/client/engine/apache5/Apache5;
public fun create (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/engine/HttpClientEngine;
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/ktor/client/engine/apache5/Apache5EngineConfig : io/ktor/client/engine/HttpClientEngineConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.ktor.client.engine.*
*
* You can learn more about client engines from [Engines](https://ktor.io/docs/http-client-engines.html).
*/
public object Apache5 : HttpClientEngineFactory<Apache5EngineConfig> {
public data object Apache5 : HttpClientEngineFactory<Apache5EngineConfig> {
override fun create(block: Apache5EngineConfig.() -> Unit): HttpClientEngine {
val config = Apache5EngineConfig().apply(block)
return Apache5Engine(config)
Expand Down
6 changes: 5 additions & 1 deletion ktor-client/ktor-client-cio/api/ktor-client-cio.klib.api
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Klib ABI Dump
// Targets: [androidNativeArm32, androidNativeArm64, androidNativeX64, androidNativeX86, iosArm64, iosSimulatorArm64, iosX64, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
// Targets: [androidNativeArm32, androidNativeArm64, androidNativeX64, androidNativeX86, iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
// Rendering settings:
// - Signature version: 2
// - Show manifest properties: true
Expand Down Expand Up @@ -62,3 +62,7 @@ final object io.ktor.client.engine.cio/CIO : io.ktor.client.engine/HttpClientEng
}

final fun (io.ktor.client.engine.cio/CIOEngineConfig).io.ktor.client.engine.cio/endpoint(kotlin/Function1<io.ktor.client.engine.cio/EndpointConfig, kotlin/Unit>): io.ktor.client.engine.cio/EndpointConfig // io.ktor.client.engine.cio/endpoint|[email protected](kotlin.Function1<io.ktor.client.engine.cio.EndpointConfig,kotlin.Unit>){}[0]

// Targets: [js]
final val io.ktor.client.engine.cio/initHook // io.ktor.client.engine.cio/initHook|{}initHook[0]
final fun <get-initHook>(): dynamic // io.ktor.client.engine.cio/initHook.<get-initHook>|<get-initHook>(){}[0]
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import io.ktor.client.engine.*
* You can learn more about client engines from [Engines](https://ktor.io/docs/http-client-engines.html).
*/
public data object CIO : HttpClientEngineFactory<CIOEngineConfig> {
init {
addToLoader()
}

override fun create(block: CIOEngineConfig.() -> Unit): HttpClientEngine =
CIOEngine(CIOEngineConfig().apply(block))
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* 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.engine.cio

Expand All @@ -14,8 +14,6 @@ import io.ktor.http.content.*
import io.ktor.util.date.*
import io.ktor.utils.io.*
import io.ktor.utils.io.CancellationException
import io.ktor.utils.io.core.*
import io.ktor.utils.io.errors.*
import io.ktor.websocket.*
import kotlinx.coroutines.*
import kotlinx.io.IOException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*
* Copyright 2014-2022 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.engine.cio

import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.sse.*
import io.ktor.client.plugins.websocket.*
import io.ktor.client.request.*
import io.ktor.client.tests.utils.*
import io.ktor.http.*
import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.test.dispatcher.*
import io.ktor.utils.io.*
import io.ktor.utils.io.core.*
import io.ktor.websocket.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
Expand All @@ -23,7 +25,7 @@ class CIOEngineTest {
private val selectorManager = SelectorManager()

@Test
fun testRequestTimeoutIgnoredWithWebSocket(): Unit = runBlocking {
fun testRequestTimeoutIgnoredWithWebSocket() = runTestWithRealTime {
val client = HttpClient(CIO) {
engine {
requestTimeout = 10
Expand All @@ -47,7 +49,7 @@ class CIOEngineTest {
}

@Test
fun testRequestTimeoutIgnoredWithSSE(): Unit = runBlocking {
fun testRequestTimeoutIgnoredWithSSE() = runTestWithRealTime {
val client = HttpClient(CIO) {
engine {
requestTimeout = 10
Expand All @@ -66,7 +68,7 @@ class CIOEngineTest {
}

@Test
fun testExpectHeader(): Unit = runBlocking {
fun testExpectHeader() = runTestWithRealTime {
val body = "Hello World"

withServerSocket { socket ->
Expand Down Expand Up @@ -94,7 +96,7 @@ class CIOEngineTest {
}

@Test
fun testNoExpectHeaderIfNoBody(): Unit = runBlocking {
fun testNoExpectHeaderIfNoBody() = runTestWithRealTime {
withServerSocket { socket ->
val client = HttpClient(CIO)
launch {
Expand All @@ -115,7 +117,7 @@ class CIOEngineTest {
}

@Test
fun testDontWaitForContinueResponse(): Unit = runBlocking {
fun testDontWaitForContinueResponse() = runTestWithRealTime {
withTimeout(30.seconds) {
val body = "Hello World\n"

Expand Down Expand Up @@ -147,7 +149,7 @@ class CIOEngineTest {
}

@Test
fun testRepeatRequestAfterExpectationFailed(): Unit = runBlocking {
fun testRepeatRequestAfterExpectationFailed() = runTestWithRealTime {
val body = "Hello World"

withServerSocket { socket ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
* Copyright 2014-2023 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.
*/
import io.ktor.client.engine.cio.*

package io.ktor.client.engine.cio

import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.test.dispatcher.*
import io.ktor.utils.io.core.*
import kotlinx.coroutines.*
import kotlin.test.*
Expand All @@ -23,7 +26,7 @@ class ConnectionFactoryTest {
}

@Test
fun testLimitSemaphore() = runBlocking {
fun testLimitSemaphore() = runTestWithRealTime {
val connectionFactory = ConnectionFactory(
selectorManager,
connectionsLimit = 2,
Expand All @@ -44,7 +47,7 @@ class ConnectionFactoryTest {
}

@Test
fun testAddressSemaphore() = runBlocking {
fun testAddressSemaphore() = runTestWithRealTime {
val connectionFactory = ConnectionFactory(
selectorManager,
connectionsLimit = 2,
Expand All @@ -67,7 +70,7 @@ class ConnectionFactoryTest {
}

@Test
fun testReleaseLimitSemaphoreWhenFailed() = runBlocking {
fun testReleaseLimitSemaphoreWhenFailed() = runTestWithRealTime {
val connectionFactory = ConnectionFactory(
selectorManager,
connectionsLimit = 2,
Expand Down
5 changes: 5 additions & 0 deletions ktor-client/ktor-client-cio/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#
target.js.browser=false
target.wasmJs.browser=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.engine.cio

import io.ktor.client.engine.*
import io.ktor.util.*
import io.ktor.utils.io.*

@Suppress("DEPRECATION")
@OptIn(ExperimentalStdlibApi::class, ExperimentalJsExport::class, InternalAPI::class)
@Deprecated("", level = DeprecationLevel.HIDDEN)
@JsExport
@EagerInitialization
public val initHook: dynamic = run {
if (PlatformUtils.IS_NODE) engines.append(CIO)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.test.junit.coroutines.*
import io.ktor.network.tls.certificates.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.test.junit.coroutines.*
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import java.io.File
Expand Down
Loading
Loading