Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

web services - MockK causing a StackOverflowException with kotlin

Hy I am trying to use MockK with Kotlin for backend services.

My development machines is windows with OpenJDK 11.0.8, for some strange reason, when I run the unit test the execution stay alive until test timeout is thrown with a following message:

bject.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)
    ? java/lang/Object.hashCode (java.base@9/Object.java:122)
    ? java/util/HashMap.hash (java.base@9/HashMap.java:339)
    ? java/util/HashMap.get (java.base@9/HashMap.java:552)
    ? jdk/internal/reflect/Reflection.filterMethods (java.base@9/Reflection.java:276)
    ? java/lang/Class.getMethodHelper (java.base@9/Class.java:1412)
    ? java/lang/Class.getMethod (java.base@9/Class.java:1338)

kotlinVersion=1.4.10

testImplementation("io.mockk:mockk:1.10.2")
testImplementation("com.ninja-squad:springmockk:2.0.3")

My java version :

openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.21.0, JRE 11 Windows 10 amd64-64-Bit Compressed References 20200715_679 (JIT enabled, AOT enabled)
OpenJ9   - 34cf4c075
OMR      - 113e54219
JCL      - 95bb504fbb based on jdk-11.0.8+10)

Here is part of my test

private val payService: PayService = mockk()
private val payServiceImpl = PayServiceImpl(payService)

@BeforeEach
fun resetmockk() {
    clearMocks(payService)
}

@Test
fun listEventError() {
    coEvery { payService.getEvents(any()) }
}

Can you give me a solution to resolve this problem ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...