scala / scala/scala-java8-compat
Future.recover does not catch exceptions that are thrown inside a CompletableFuture
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 438
- Forks
- 63
- Avg merge
- 5h 12m
- Merged PRs (30d)
- 2
Description
I've been using the aws dynamodb async sdk, but I find that I cannot catch exceptions after I convert a CompletableFuture to Scala.
When I run
client
.createTable(tableSchema.createTableRequest(tableName))
.thenApply[Unit](_ => Unit)
.exceptionally {
case _: Throwable => // exception is now property handled
}
I can successfully catch the exception.
However when I run
import scala.compat.java8.FutureConverters.toScala
val cf = client
.createTable(tableSchema.createTableRequest(tableName))
toScala(cf).recover {
case _: Throwable => // never gets executed
}
I cannot actually catch the exception. Any clues on why?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with scala.compat.java8.FutureConverters.toScala and compare its exception behavior with CompletableFuture.exceptionally using the examples in the issue. Trace how exceptions from the CompletableFuture are propagated, then verify that Future.recover handles them as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100