StackOverflowError using Kotlin 1.7.20
See original GitHub issueContext
- MockK version: 1.12.8
- ByteBuddy version: 1.12.13
- OS: MacOS
- Kotlin version: 1.7.20
- JDK version: 18.0.2
- JUnit version: 5.9.0
- Type of test: unit test (no containers)
Failure Logs
Cannot invoke "io.vertx.ext.mongo.MongoClient.replaceDocumentsWithOptions(String, io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.ext.mongo.UpdateOptions)" because the return value of "kn.tqt.db.store.base.AbstractRepository.getDbClient()" is null
java.lang.NullPointerException: Cannot invoke "io.vertx.ext.mongo.MongoClient.replaceDocumentsWithOptions(String, io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.ext.mongo.UpdateOptions)" because the return value of "kn.tqt.db.store.base.AbstractRepository.getDbClient()" is null
at kn.tqt.db.store.base.AbstractRepository.upsert$suspendImpl(AbstractRepository.kt:47)
at kn.tqt.db.store.base.AbstractRepository.upsert(AbstractRepository.kt)
Stack trace
java.lang.StackOverflowError: null
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.of(TypeDescription.java:2008)
at net.bytebuddy.description.type.TypeList$Generic$ForDetachedTypes.attachVariables(TypeList.java:561)
at net.bytebuddy.description.method.MethodDescription$Latent.getTypeVariables(MethodDescription.java:1455)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findVariable(TypeVariableSource.java:157)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:172)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2035)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1946)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5856)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1881)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1946)
at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5059)
at net.bytebuddy.description.method.ParameterDescription$Latent.getType(ParameterDescription.java:805)
at net.bytebuddy.description.method.ParameterList$AbstractBase.asTypeList(ParameterList.java:107)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toString(MethodDescription.java:1006)
at java.base/java.lang.String.valueOf(String.java:4213)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
at net.bytebuddy.description.TypeVariableSource$AbstractBase.findExpectedVariable(TypeVariableSource.java:174)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:2035)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1946)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5856)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1881)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1946)
at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5059)
at net.bytebuddy.description.method.ParameterDescription$Latent.getType(ParameterDescription.java:805)
at net.bytebuddy.description.method.ParameterList$AbstractBase.asTypeList(ParameterList.java:107)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.toString(MethodDescription.java:1006)
at java.base/java.lang.String.valueOf(String.java:4213)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
...
Minimal reproducible code (the gist of this issue)
mockk<TotalBidSummaryRepository>().apply {
coEvery { upsert(any()) } coAnswers {
val summary = firstArg<TotalBidSummary>()
state[summary.rfqNum] = summary
true
}
coEvery { findNullable(any()) } coAnswers {
state[firstArg()]?.deepCopy()
}
coEvery { find(any()) } coAnswers {
state[firstArg()]!!.deepCopy()
}
}
class TotalBidSummaryRepository(dbClient: MongoClient) :
AbstractRepository<TotalBidSummary>(dbClient, "TotalBidSummary", TotalBidSummary::class)
abstract class AbstractRepository<T : Any>(
dbClient: MongoClient,
collectionName: String,
clazz: KClass<T>
) : AbstractReadOnlyRepository<T>(dbClient, collectionName, clazz) {
P.S. maybe byte-buddy issue?
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Upgrading Kotlin Gradle plugins to version 1.7.20 causes ...
I have Kotlin/Spring Boot project that is using the following Kotlin-Gradle plugins: ... Facing the same issue with Kotlin 1.7.20.
Read more >What's new in Kotlin 1.7.0
The new Kotlin K2 compiler is in Alpha now, and it offers serious ... itself recursively 100,000 times, no StackOverflowError is thrown:.
Read more >What's new in Kotlin 1.7.20
The Kotlin 1.7.20 release is out! Here are some highlights from this release: The new Kotlin K2 compiler supports all-open , SAM with...
Read more >FAQ | Kotlin
Is Kotlin compatible with the Java programming language? ... StackOverflow and more actively on the Kotlin Slack (with close to 30000 ...
Read more >Anybody else getting a lot of build failures if you dependab
plugins { kotlin("jvm") version "1.7.20" kotlin("plugin.serialization") ... 27 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.20.
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
Same here with a similar setup. Works with Kotlin 1.7.10 but fails with 1.7.20, if this helps.
I ran into similar issue. My minimal repro case is:
It also works with kotlin 1.7.10, but fails with 1.7.20. The error we see when running the test as a part of our Android project is:
After extracting the repro case to pure jvm console app, I also see the stackoverflow error before: