RFR: 8331987: Enhance stacktrace clarity for CompletableFuture CancellationException [v2]

Viktor Klang vklang at openjdk.org
Mon May 13 23:59:17 UTC 2024


> This change adds wrapping of the CancellationException produced by CompletableFuture::get() and CompletableFuture::join() to add more diagnostic information and align better with FutureTask.
> 
> Running the sample code from the JBS issue in JShell will produce the following:
> 
> 
> jshell> java.util.concurrent.CancellationException: 
> 	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:392)
> 	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
> 	at REPL.$JShell$18.m2($JShell$18.java:10)
> 	at REPL.$JShell$17.m1($JShell$17.java:8)
> 	at REPL.$JShell$16B.lambda$main$0($JShell$16B.java:8)
> 	at java.base/java.lang.Thread.run(Thread.java:1575)
> Caused by: java.util.concurrent.CancellationException
> 	at java.base/java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2510)
> 	at REPL.$JShell$16B.lambda$main$1($JShell$16B.java:11)
> 	... 1 more

Viktor Klang has updated the pull request incrementally with one additional commit since the last revision:

  Adding CancellationException detail message to CompletableFuture

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/19219/files
  - new: https://git.openjdk.org/jdk/pull/19219/files/641bbfe3..078930ab

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=19219&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=19219&range=00-01

  Stats: 14 lines in 2 files changed: 0 ins; 0 del; 14 mod
  Patch: https://git.openjdk.org/jdk/pull/19219.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19219/head:pull/19219

PR: https://git.openjdk.org/jdk/pull/19219


More information about the core-libs-dev mailing list