Skip to content

Commit

Permalink
RetryKoraAspect simplified and value class bug fixed (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodforGod authored Aug 2, 2023
1 parent 0b1aa03 commit ab111ae
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ class RetryableKoraAspect(val resolver: Resolver) : KoraAspect {

private fun buildBodySync(method: KSFunctionDeclaration, superCall: String, retryName: String, fieldRetrier: String): CodeBlock {
return CodeBlock.builder()
.add("return %L.asState()", fieldRetrier).indent().add("\n")
.add("%L.asState()", fieldRetrier).indent().add("\n")
.controlFlow(".use { _state ->", fieldRetrier) {
addStatement("val _suppressed = %T<Exception>();", ArrayList::class)
addStatement("lateinit var _result: %T", method.returnType?.resolve()?.toTypeName())
controlFlow("while (true)") {
controlFlow("try") {
add("_result = ").add(buildMethodCall(method, superCall)).add("\n")
addStatement("break")
add("return ").add(buildMethodCall(method, superCall)).add("\n")
nextControlFlow("catch (_e: Exception)")
addStatement("val _status = _state.onException(_e)")
controlFlow("when (_status)") {
Expand Down Expand Up @@ -108,10 +106,8 @@ class RetryableKoraAspect(val resolver: Resolver) : KoraAspect {
}
}
}
addStatement("return@use _result")
}
.unindent()
.add("\n")
.build()
}

Expand Down

0 comments on commit ab111ae

Please sign in to comment.