kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.client.request.HttpRequestPipeline@545e18f8
See original GitHub issueKtor Version
implementation("io.ktor:ktor-client-ios:1.1.1")
Ktor Engine Used(client or server and name)
Client
JVM Version, Operating System and Relevant Context
MBP 2017 JVM 1.8
Feedback
This exception was printed out,and the test can’t print out the expected result
suspend fun getDemoJSONDataFromNet(): String {
val result = client.get<String>("https://en.wikipedia.org/wiki/Main_Page")
Logger.d(tag, "the return data is $result")
return result
}
fun getDataIos(callBack: (result: String) -> Unit) {
runBlocking {
val job = async {
val result = HttpUtil.getDemoJSONDataFromNet()
Logger.d("SimpleIos","result value is $result")
callBack(result)
}
job.await()
}
}
@Test
fun testGetData() {
getDataIos {
println(it)
}
}
Exception Log:
Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift.
Other exceptions can be propagated as NSError if method has or inherits @Throws annotation.
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.client.request.HttpRequestPipeline@2ef2a08
at 0 app 0x000000010dba2896 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 70
at 1 app 0x000000010dba27b6 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 70
at 2 app 0x000000010dba40e6 kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException + 70
at 3 app 0x000000010dc3c6b8 ThrowInvalidMutabilityException + 280
at 4 app 0x000000010dc5ee48 MutationCheck + 24
at 5 app 0x000000010dce8a83 kfun:io.ktor.util.pipeline.Pipeline.<set-interceptors>#internal + 67
at 6 app 0x000000010dce86a6 kfun:io.ktor.util.pipeline.Pipeline.notSharedInterceptorsList#internal + 70
at 7 app 0x000000010dce84d6 kfun:io.ktor.util.pipeline.Pipeline.cacheInterceptors#internal + 710
at 8 app 0x000000010dce6292 kfun:io.ktor.util.pipeline.Pipeline.sharedInterceptorsList#internal + 98
at 9 app 0x000000010dce61ca kfun:io.ktor.util.pipeline.Pipeline.createContext$ktor-utils(#GENERIC_kotlin.Any;#GENERIC_kotlin.Any)io.ktor.util.pipeline.PipelineExecutor<#GENERIC_kotlin.Any> + 90
at 10 app 0x000000010dce60f0 kfun:io.ktor.util.pipeline.Pipeline.execute(#GENERIC_kotlin.Any;#GENERIC_kotlin.Any)#GENERIC_kotlin.Any + 96
at 11 app 0x000000010dd313a8 kfun:io.ktor.client.HttpClient.$execute$COROUTINE$1.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? + 296
at 12 app 0x000000010dd31522 kfun:io.ktor.client.HttpClient.execute(io.ktor.client.request.HttpRequestBuilder)io.ktor.client.call.HttpClientCall + 130
at 13 app 0x000000010dd32696 kfun:io.ktor.client.call.$call$COROUTINE$3.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? + 758
at 14 app 0x000000010dd32852 kfun:io.ktor.client.call.call@io.ktor.client.HttpClient.(kotlin.coroutines.SuspendFunction1<io.ktor.client.request.HttpRequestBuilder,kotlin.Unit>)io.ktor.client.call.HttpClientCall + 130
at 15 app 0x000000010dd330eb kfun:io.ktor.client.call.call@io.ktor.client.HttpClient.(io.ktor.client.request.HttpRequestBuilder)io.ktor.client.call.HttpClientCall + 123
at 16 app 0x000000010db97f3f kfun:sample.HttpUtil.$getDemoJSONDataFromNet$COROUTINE$0.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? + 1551
at 17 app 0x000000010db97821 kfun:sample.HttpUtil.getDemoJSONDataFromNet()kotlin.String + 113
at 18 app 0x000000010dba0de9 kfun:sample.$getDataIos$lambda-1$lambda-0$COROUTINE$3.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? + 313
at 19 app 0x000000010dbd4801 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 385
at 20 app 0x000000010dca7b89 kfun:kotlinx.coroutines.DispatchedTask.run() + 1129
at 21 app 0x000000010dca92d6 kfun:kotlinx.coroutines.EventLoopImpl.processNextEvent()ValueType + 422
at 22 app 0x000000010dccf7f7 kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal + 263
at 23 app 0x000000010dccf5d7 kfun:kotlinx.coroutines.runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,#GENERIC>)Generic + 983
at 24 app 0x000000010dccfb4c kfun:kotlinx.coroutines.runBlocking$default(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,#GENERIC>;kotlin.Int)Generic + 204
at 25 app 0x000000010dba06e4 kfun:sample.getDataIos(kotlin.Function1<kotlin.String,kotlin.Unit>) + 100
at 26 app 0x000000010dba0618 kfun:sample.main(kotlin.Array<kotlin.String>) + 216
at 27 iosApp 0x000000010d897774 $S6iosApp14ViewControllerC11viewDidLoadyyFTo + 36
at 28 UIKitCore 0x0000000112ea84e1 -[UIViewController loadViewIfRequired] + 1186
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
android - mutation attempt of frozen io.ktor.client.request ...
This seems to be a bug in ktor 2.0. As a workaround, you can use the new memory model (at least this fixed...
Read more >mutation attempt of frozen io.ktor.client.request ...
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.client.request.HttpRequestPipeline ; Type, Bug B ; Subsystem, Client.
Read more >Making requests | Ktor
After setting up the client, you can make HTTP requests. The main way of making HTTP requests is the request function that can...
Read more >InvalidMutabilityException - Kotlin Programming Language
Exception thrown whenever we attempt to mutate frozen objects. Parameters. where - a frozen object that was attempted to mutate. Constructors. Native.
Read more >Kotlin.Native.Concurrent.Invalidmutabilityexception - ADocLib
InvalidMutabilityException : mutation attempt of frozen object @72c18 at 0 ... As of v.1.4.0 ktor client is not working on Kotlin/native iOS due...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t freeze your HttpClient, it doesn’t work.
That means don’t put it inside an
object
for example, or inside an instance of a class stored inside anobject
, etcFixed in 1.4.1