Getting null for findFileByIoFile randomly

已回答

I'm getting a KotlinNullPointerException in the return statement of the given code. Any idea what could be the reason? It happens randomly, and never happens when I have a debugging breakpoints in place. 

private fun getProjectOutFolder(): VirtualFile {
val outFolder = File(project.basePath + File.separator + "out")
logger.info("Creating out folder: $outFolder")
if (outFolder.exists()) {
val outFolderDeleted = outFolder.deleteRecursively()
logger.info("deleting existing out folder: $outFolderDeleted")
}
val outFolderCreated = outFolder.mkdirs()
logger.info("created out folder: $outFolderCreated")
return localFileSystem.findFileByIoFile(outFolder)!!
}
0

You should probably use refreshAndFindFileByIoFile instead since you are creating a new directory.

0

请先登录再写评论。