Java 在kotlin内处理completionStage响应 fun addTypeInformationIfRequired():CompletableFuture{ val result=client.asyncSend(请求)//以CompletionStage形式获取响应 val typesFuture=result.thenApply{ MultistreamlinePropertyContentResult-> result.entries.map{ it.key to it.value.typeId .map{typeId->get(typeId)} .orElse(“默认值”) }.toMap() }.toCompletableFuture() }
即使在对返回的CompletableFuture调用get()之后,也无法在调用期间从映射中获取值。thenApply()应该能够处理结果尚未就绪的情况。我在这里做错了什么?我怎样才能使它作为同步处理工作Java 在kotlin内处理completionStage响应 fun addTypeInformationIfRequired():CompletableFuture{ val result=client.asyncSend(请求)//以CompletionStage形式获取响应 val typesFuture=result.thenApply{ MultistreamlinePropertyContentResult-> result.entries.map{ it.key to it.value.typeId .map{typeId->get(typeId)} .orElse(“默认值”) }.toMap() }.toCompletableFuture() },java,kotlin,asynchronous,Java,Kotlin,Asynchronous,即使在对返回的CompletableFuture调用get()之后,也无法在调用期间从映射中获取值。thenApply()应该能够处理结果尚未就绪的情况。我在这里做错了什么?我怎样才能使它作为同步处理工作 fun addTypeInformationIfRequired(): CompletableFuture<Map<Long!,Type>> { val result = client.asyncSend(request) // get response as Comp
fun addTypeInformationIfRequired(): CompletableFuture<Map<Long!,Type>> {
val result = client.asyncSend(request) // get response as CompletionStage
val typesFuture = result.thenApply {
multiStreamlinedPropertyContentResult ->
result.entries.map {
it.key to it.value.typeId
.map { typeId -> get(typeId) }
.orElse("Default_Value")
}.toMap()
}.toCompletableFuture()
}