Strengthen deprecations

This commit is contained in:
Sergey Mashkov
2019-03-12 15:45:29 +03:00
parent 7fa6a8ac83
commit 32d14c33f2
12 changed files with 25 additions and 117 deletions

View File

@@ -131,11 +131,3 @@ class ReceivePipelineException(
class NoTransformationFoundException(from: KClass<*>, to: KClass<*>) : UnsupportedOperationException() {
override val message: String? = "No transformation found: $from -> $to"
}
@Deprecated(
"[NoTransformationFound] is deprecated. Use [NoTransformationFoundException] instead",
ReplaceWith("NoTransformationFoundException"),
DeprecationLevel.ERROR
)
@Suppress("KDocMissingDocumentation")
typealias NoTransformationFound = NoTransformationFoundException

View File

@@ -14,10 +14,14 @@ open class HttpClientEngineConfig {
* The [CoroutineDispatcher] that will be used for the client requests.
*/
@Deprecated(
"Custom dispatcher is deprecated. Consider using threadsCount instead.",
level = DeprecationLevel.ERROR
"Binary compatibility.",
level = DeprecationLevel.HIDDEN
)
var dispatcher: CoroutineDispatcher? = null
var dispatcher: CoroutineDispatcher?
get() = null
set(_) {
throw UnsupportedOperationException("Custom dispatcher is deprecated. Use threadsCount instead.")
}
/**
* Network threads count

View File

@@ -36,16 +36,13 @@ interface HttpRequest : HttpMessage, CoroutineScope {
*/
val attributes: Attributes
/**
* A [Job] representing the process of this request.
*/
@Deprecated(
"[executionContext] is deprecated. Use coroutineContext instead",
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith("coroutineContext")
"Binary compatibility.",
level = DeprecationLevel.HIDDEN
)
@Suppress("unused", "KDocMissingDocumentation")
val executionContext: Job
get() = error("[executionContext] is deprecated. Use coroutineContext instead")
get() = coroutineContext[Job]!!
/**
* An [OutgoingContent] representing the request body

View File

@@ -44,9 +44,8 @@ interface HttpResponse : HttpMessage, CoroutineScope, Closeable {
* A [Job] representing the process of this response.
*/
@Deprecated(
"executionContext is deprecated. Use coroutineContext instead.",
replaceWith = ReplaceWith("coroutineContext"),
level = DeprecationLevel.ERROR
"Binary compatibility.",
level = DeprecationLevel.HIDDEN
)
val executionContext: Job
get() = coroutineContext[Job]!!

View File

@@ -28,17 +28,11 @@ inline var DefaultWebSocketServerSession.timeout: Duration
timeoutMillis = newDuration.toMillis()
}
/**
* Launch pinger coroutine on [coroutineContext] websocket for [session] that is sending ping every specified [period],
* waiting for and verifying client's pong frames. It is also handling [timeout] and sending timeout close frame
* to the dedicated [out] channel in case of failure
*/
@Deprecated(
"Use pinger on CoroutineScope",
ReplaceWith("session.pinger(session.outgoing, period, timeout, out, pool)"),
level = DeprecationLevel.ERROR
"Binary compatibility.",
level = DeprecationLevel.HIDDEN
)
@Suppress("UNUSED_PARAMETER")
@Suppress("UNUSED_PARAMETER", "unused", "KDocMissingDocumentation")
fun pinger(
session: WebSocketSession,
period: Duration,

View File

@@ -1,22 +1,5 @@
package io.ktor.http
/**
* Set `Content-Type` header
*/
@Suppress("unused", "UNUSED_PARAMETER", "DeprecatedCallableAddReplaceWith")
@Deprecated("Content-Type need to be passed in OutgoingContent.contentType", level = DeprecationLevel.ERROR)
fun HeadersBuilder.contentType(contentType: ContentType): Unit = TODO("Not supported anymore")
/**
* Set `Content-Length` header
*/
@Deprecated(
"Content-Length need to be passed in OutgoingContent.contentLength",
level = DeprecationLevel.ERROR
)
@Suppress("unused", "UNUSED_PARAMETER", "DeprecatedCallableAddReplaceWith")
fun HeadersBuilder.contentLength(length: Long): Unit = TODO("Not supported anymore")
/**
* Set `E-Tag` header
*/

View File

@@ -41,21 +41,6 @@ val HttpPipelineWriterCoroutine: CoroutineName = CoroutineName("http-pipeline-wr
*/
val RequestHandlerCoroutine: CoroutineName = CoroutineName("request-handler")
@Suppress("KDocMissingDocumentation", "UNUSED_PARAMETER", "DeprecatedCallableAddReplaceWith")
@Deprecated(
"Use startConnectionPipeline with CoroutineScope receiver",
level = DeprecationLevel.ERROR
)
fun startConnectionPipeline(
input: ByteReadChannel,
output: ByteWriteChannel,
parentJob: CoroutineContext?,
ioContext: CoroutineContext,
callContext: CoroutineContext,
timeout: WeakTimeoutQueue,
handler: HttpRequestHandler
): Job = TODO("Not supported anymore")
/**
* Start connection HTTP pipeline invoking [handler] for every request.
* Note that [handler] could be invoked multiple times concurrently due to HTTP pipeline nature

View File

@@ -16,15 +16,11 @@ private val PongerCoroutineName = CoroutineName("ws-ponger")
private val PingerCoroutineName = CoroutineName("ws-pinger")
/**
* Launch a ponger actor job on the [coroutineContext] for websocket [session].
* It is acting for every client's ping frame and replying with corresponding pong
*/
@Deprecated(
"Use ponger with CoroutineScope receiver",
ReplaceWith("session.ponger(session.outgoing, pool)"),
level = DeprecationLevel.ERROR
"Binary compatibility.",
level = DeprecationLevel.HIDDEN
)
@Suppress("KDocMissingDocumentation", "unused")
fun ponger(
session: WebSocketSession,
pool: ObjectPool<ByteBuffer> = KtorDefaultPool

View File

@@ -2,7 +2,6 @@ package io.ktor.http.cio.websocket
import kotlinx.coroutines.*
import kotlinx.io.core.*
import kotlinx.io.core.ByteOrder
/**
* A frame received or ready to be sent. It is not reusable and not thread-safe
@@ -46,7 +45,6 @@ actual sealed class Frame private actual constructor(
*/
actual class Close actual constructor(data: ByteArray) : Frame(true, FrameType.CLOSE, data) {
actual constructor(reason: CloseReason) : this(buildPacket {
byteOrder = ByteOrder.BIG_ENDIAN
writeShort(reason.code)
writeStringUtf8(reason.message)
})

View File

@@ -29,7 +29,7 @@ class TestApplicationResponse(
}
@Suppress("CanBePrimaryConstructorProperty")
@Deprecated("Will be removed from public API")
@Deprecated("Will be removed from public API", level = DeprecationLevel.ERROR)
val readResponse: Boolean = readResponse
/**
@@ -80,7 +80,7 @@ class TestApplicationResponse(
override suspend fun responseChannel(): ByteWriteChannel {
val result = ByteChannel(autoFlush = true)
if (@Suppress("DEPRECATION") readResponse) {
if (@Suppress("DEPRECATION_ERROR") readResponse) {
launchResponseJob(result)
}
@@ -111,7 +111,7 @@ class TestApplicationResponse(
*/
@InternalAPI
@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("Will be removed")
@Deprecated("Will be removed", level = DeprecationLevel.ERROR)
suspend fun flush() {
awaitForResponseCompletion()
}

View File

@@ -1,40 +0,0 @@
@file:Suppress("KDocMissingDocumentation", "DEPRECATION")
package io.ktor.pipeline
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
typealias ContextDsl = io.ktor.util.pipeline.ContextDsl
@Deprecated("Import from another package", level = DeprecationLevel.ERROR)
typealias InvalidPhaseException = io.ktor.util.pipeline.InvalidPhaseException
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
typealias Pipeline<TSubject, TContext> = io.ktor.util.pipeline.Pipeline<TSubject, TContext>
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
typealias PipelineContext<TSubject, TContext> = io.ktor.util.pipeline.PipelineContext<TSubject, TContext>
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
typealias PipelineInterceptor<TSubject, TContext> = io.ktor.util.pipeline.PipelineInterceptor<TSubject, TContext>
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
typealias PipelinePhase = io.ktor.util.pipeline.PipelinePhase
@Suppress("DEPRECATION_ERROR")
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
suspend inline fun <TContext : Any> Pipeline<Unit, TContext>.execute(context: TContext) = execute(context, Unit)
@Suppress("DEPRECATION_ERROR")
@Deprecated("Import it from another package", level = DeprecationLevel.ERROR)
inline fun <reified TSubject : Any, TContext : Any> Pipeline<*, TContext>.intercept(
phase: PipelinePhase,
noinline block: suspend PipelineContext<TSubject, TContext>.(TSubject) -> Unit
) {
intercept(phase) interceptor@{ subject ->
subject as? TSubject ?: return@interceptor
@Suppress("UNCHECKED_CAST")
val reinterpret = this as? PipelineContext<TSubject, TContext>
reinterpret?.block(subject)
}
}

View File

@@ -6,18 +6,18 @@ import java.util.*
/**
* Creates [LocalDateTime] from this [Date]
*/
@Deprecated("Shouldn't be used outside of ktor")
@InternalAPI
fun Date.toLocalDateTime(): LocalDateTime = LocalDateTime.ofInstant(toInstant(), ZoneId.systemDefault())
/**
* Creates [ZonedDateTime] from this [Date]
*/
@Suppress("DEPRECATION")
@Deprecated("Shouldn't be used outside of ktor")
@InternalAPI
fun Date.toZonedDateTime(): ZonedDateTime = ZonedDateTime.ofInstant(toInstant(), GreenwichMeanTime)
/**
* [ZoneId] for GMT
*/
@Deprecated("Shouldn't be used outside of ktor")
@InternalAPI
val GreenwichMeanTime: ZoneId = ZoneId.of("GMT")