override fun getExecutable()

in jetbrains-core/src/software/aws/toolkits/jetbrains/core/executables/ExecutableManager.kt [112:138]


    override fun getExecutable(type: ExecutableType<*>): CompletionStage<ExecutableInstance> {
        val future = CompletableFuture<ExecutableInstance>()
        ApplicationManager.getApplication().executeOnPooledThread {
            val loaded = internalState[type.id]
            if (loaded == null) {
                future.complete(load(type, null))
                return@executeOnPooledThread
            }

            val (persisted, instance, lastValidated) = loaded
            val lastKnownFileTime = persisted.lastKnownFileTime?.let { FileTime.fromMillis(it) }

            future.complete(
                when {
                    // If this is an autoresolved path, and has been updated, remove the autoresolvedness and revalidate
                    instance is ExecutableWithPath && persisted.autoResolved == true && instance.executablePath.isNewerThan(lastKnownFileTime) ->
                        validateAndSave(type, instance.executablePath, autoResolved = false)
                    // If it is valid, and has not changed, we return the existing cached one
                    instance is ExecutableInstance.Executable && instance.executablePath.lastModifiedOrNull() == lastValidated ->
                        instance
                    else ->
                        load(type, persisted)
                }
            )
        }
        return future
    }