Initializing a Json instance on a background thread fails in native
See original GitHub issueIn 0.11.0, when you create a Json
instance on a background thread, K/N throws an IncorrectDereferenceException
because initializing one touches the private defaultJsonModule
global here. I believe the fix is to just mark that global as @SharedImmutable
.
You can workaround this by declaring a global Json that’s immutable, which (I think) will get setup and frozen during K/N runtime init. Seems to be working locally
@SharedImmutable
private val DEFAULT_JSON = Json(your_config)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
unable to create new native thread while using Executor ...
The main idea of the solution is to initialize the ExecutorService instance only once and reuse it on each request (see comments above)....
Read more >JSON and serialization - Flutter documentation
The cookbook contains a more comprehensive worked example of using JSON model classes, using an isolate to parse the JSON file on a...
Read more >Loading JSON data with async/await – iOS & SwiftUI Tutorial
The tutorial and sample project shows how JSON data is loaded in the background using the new Xcode 13 feature async/await via the ......
Read more >Karate | Test Automation Made Simple.
For example a lot of Java projects directly (or indirectly) depend on Netty or ... Now that we have seen how JSON is...
Read more >After recent update json schema validation fails - Airbyte
Maybe some magic is happening in the background?! In short, I keep getting that json schema validation error and cannot run my connections....
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
You need to add
kotlin.native.initRuntimeIfNeeded()
before callingDEFAULT_JSON .parse
I had the same problem Here is my code that works :
` // INTERNAL @kotlin.native.ThreadLocal private val parser = Json.nonstrict // or strict in your case
Yep agree. They can be closed at the same time, or feel free to close this as dup 😃