java.lang.ArrayIndexOutOfBoundsException in JsonStringBuilder 1.2.0
See original GitHub issueDescribe the bug java.lang.ArrayIndexOutOfBoundsException when using Json.encodeToString() with some input, idk what exactly is causing it Stacktrace:
java.lang.ArrayIndexOutOfBoundsException: Index 473 out of bounds for length 473
at kotlinx.serialization.json.internal.JsonStringBuilder.appendStringSlowPath(JsonStringBuilder.kt:84)
at kotlinx.serialization.json.internal.JsonStringBuilder.appendQuoted(JsonStringBuilder.kt:61)
at kotlinx.serialization.json.internal.Composer.printQuoted(Composers.kt:42)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeString(StreamingJsonEncoder.kt:203)
at kotlinx.serialization.internal.StringSerializer.serialize(Primitives.kt:139)
at kotlinx.serialization.internal.StringSerializer.serialize(Primitives.kt:136)
at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:211)
at kotlinx.serialization.json.Json.encodeToString(Json.kt:80)
at io.ktor.client.features.json.serializer.KotlinxSerializer.writeContent$ktor_client_serialization(KotlinxSerializer.kt:30)
at io.ktor.client.features.json.serializer.KotlinxSerializer.write(KotlinxSerializer.kt:26)
at io.ktor.client.features.json.JsonFeature$Feature$install$1.invokeSuspend(JsonFeature.kt:149)
at io.ktor.client.features.json.JsonFeature$Feature$install$1.invoke(JsonFeature.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:246)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(SuspendFunctionGun.kt:126)
at io.ktor.client.features.HttpCallValidator$Companion$install$1.invokeSuspend(HttpCallValidator.kt:113)
at io.ktor.client.features.HttpCallValidator$Companion$install$1.invoke(HttpCallValidator.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:246)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
at io.ktor.client.features.HttpRequestLifecycle$Feature$install$1.invokeSuspend(HttpRequestLifecycle.kt:37)
at io.ktor.client.features.HttpRequestLifecycle$Feature$install$1.invoke(HttpRequestLifecycle.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:246)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
at io.ktor.client.HttpClient.execute(HttpClient.kt:191)
at io.ktor.client.statement.HttpStatement.executeUnsafe(HttpStatement.kt:104)
at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:43)
at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:58)
at me.melijn.melijnbot.internals.services.twitter.TwitterService.postNewTweets(TwitterService.kt:396)
at me.melijn.melijnbot.internals.services.twitter.TwitterService.access$postNewTweets(TwitterService.kt:26)
at me.melijn.melijnbot.internals.services.twitter.TwitterService$service$1.invokeSuspend(TwitterService.kt:45)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:46)
at io.ktor.client.features.HttpCallValidator$Companion$install$1.invokeSuspend(HttpCallValidator.kt:113)
at io.ktor.client.features.HttpRequestLifecycle$Feature$install$1.invokeSuspend(HttpRequestLifecycle.kt:37)
at io.ktor.client.HttpClient.execute(HttpClient.kt:191)
at io.ktor.client.statement.HttpStatement.executeUnsafe(HttpStatement.kt:104)
at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:43)
at me.melijn.melijnbot.internals.services.twitter.TwitterService.postNewTweets(TwitterService.kt:396)
at me.melijn.melijnbot.internals.services.twitter.TwitterService$service$1.invokeSuspend(TwitterService.kt:45)
at me.melijn.melijnbot.internals.threading.RunnableTask$run$1.invokeSuspend(Task.kt:140)
at me.melijn.melijnbot.internals.threading.TaskManager$async$1$1.invokeSuspend(TaskManager.kt:29)
at me.melijn.melijnbot.internals.threading.Task.run(Task.kt:12)
at me.melijn.melijnbot.internals.threading.TaskManager$async$1.invokeSuspend(TaskManager.kt:30)
To Reproduce
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Json.encodeToString("""{"avatar_url":"https://cdn.discordapp.com/avatars/384333349063491584/8adca1bddf8c5c46c7deed3edbd80d60.png","embeds":[{"color":1741274,"author":{"icon_url":"https://pbs.twimg.com/profile_images/1381321181719109633/4bpPMaer_normal.jpg","name":"Merlijn replied:","url":"https://twitter.com/@PixelHamster/status/1390719238155952129"},"description":"[@shroomizu](https://twitter.com/shroomizu) time for a pro controller","type":"rich","timestamp":"2021-05-07T17:24:39Z"}],"username":"Merijn"}""")
Expected behavior Returns the String that was passed to the encodeToString() fucntion
Environment
- Kotlin version: 1.5.0
- Library version: 1.2.0
- Kotlin platforms: JVM
- Gradle version: 7.0
- Other relevant context JRE 15.0.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top Results From Across the Web
What causes a java.lang.ArrayIndexOutOfBoundsException ...
The array goes out of bounds when the index you try to manipulate is more than the length of the array. For correctness,...
Read more >java.lang.ArrayIndexOutOfBoundsException: 0 in 1.2.124
Using databases created with 1.2.124 in a desktop app, I'm occasionally getting error reports from users with this exception: org.h2.jdbc.
Read more >The game crashed whilst initializing game Error: java.lang ...
I heard that a java update might help, tried that then the game won't ... ArrayIndexOutOfBoundsException: 0 Exit-Code: -1 ... at java.lang.
Read more >java.lang.ArrayIndexOutOfBoundsException, when executing ...
ArrayIndexOutOfBoundsException: Array index out of range", occurs when using IBM® Rational® ClearQuest® TestManager (CQTM) for test execution.
Read more >java.lang.ArrayIndexOutOfBoundsException when closing a ...
We recently experienced a flurry of SQLExceptions caused by an ArrayIndexOutOfBounds exception within the JDBC Driver in one of our web ...
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
I’ll close this as a duplicate. We’ll fix this bug and release 1.2.1 soon
Reproducer: