IDEA IllegalStateException:使用Kotlin

时间:2017-04-02 18:59:55

标签: intellij-idea kotlin

昨天我正在处理我的代码库,当我突然在IDEA日志中看到这个时,我正在对我的代码运行单元测试:

  

错误:Kotlin:[内部错误] java.lang.IllegalStateException:   服务正在消亡       在org.jetbrains.kotlin.daemon.common.CompileService $ CallResult $ Dying.get(CompileService.kt:60)       在org.jetbrains.kotlin.daemon.common.CompileService $ CallResult $ Dying.get(CompileService.kt:59)       在org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.compileWithDaemon(JpsKotlinCompilerRunner.kt:127)       at or.::,,,,,,,,,,,       at or.::,,,,,,,,,,,       在org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:115)       在org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner.runK2JvmCompiler(JpsKotlinCompilerRunner.kt:65)       在org.jetbrains.kotlin.jps.build.KotlinBuilder.compileToJvm(KotlinBuilder.kt:740)       在org.jetbrains.kotlin.jps.build.KotlinBuilder.doCompileModuleChunk(KotlinBuilder.kt:458)       在org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:264)       在org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:181)       在org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1282)       在org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:956)       在org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1028)       在org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:915)       在org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:741)       在org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:387)       在org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:195)       在org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)       在org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)       在org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)       在org.jetbrains.jps.cmdline.BuildMain $ MyMessageHandler $ 1.run(BuildMain.java:238)       在org.jetbrains.jps.service.impl.SharedThreadPoolImpl $ 1.run(SharedThreadPoolImpl.java:44)       at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)       at java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在java.lang.Thread.run(Thread.java:745)

这是四月愚蠢的JetBrains的笑话吗?

我以前从未见过这个。 killall java和IDEA重新启动解决了这个问题,我无法重现这个问题。这是有记录的东西(我没有在谷歌上发现任何点击)或只是编译Kotlin代码时IDEA的一次性故障? 此错误意味着什么?

请注意我运行的单元测试是一个简单的探索性测试,我认为这与此无关:

internal fun fetchAsListWithSiblings(): List<Message<T>> {
    val first = this
    var currentMsg = first
    val result = mutableListOf(currentMsg)
    while(currentMsg.next.isPresent) {
        val next = currentMsg.next.get()
        currentMsg = next
        result.add(next)
    }
    return result
}


@Test
fun shouldFetchSiblingsWhenFetchSiblingsIsCalledWithMultipleSiblings() {
    val expected = listOf("foo", "bar", "baz")
    val messages = Message.createMultiple(expected)

    assertThat(messages.fetchAsListWithSiblings().map { it.payload }).isEqualTo(expected)
}

1 个答案:

答案 0 :(得分:5)

这是已知问题 - 并行编译开始时的竞争条件。通常重复构建解决它。以下是YouTrack中的相关issue KT-15562。这个问题最终应该在Kotlin 1.1.2版本中得到解决。