RFR: 8312436: CompletableFuture never completes when 'Throwable.toString()' method throws Exception

Viktor Klang vklang at openjdk.org
Fri May 10 14:42:23 UTC 2024


On Mon, 29 Apr 2024 11:48:08 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Primarily offering this PR for discussion, as Throwables throwing exceptions on toString(), getLocalizedMessage(), or getMessage() seems like a rather unreasonable thing to do.
>> 
>> Nevertheless, there is some things we can do, as witnessed in this PR.
>
> src/java.base/share/classes/java/util/concurrent/CompletableFuture.java line 310:
> 
>> 308: 
>> 309:     static CompletionException wrapInCompletionException(Throwable t) {
>> 310:         if (t == null)
> 
> Is there any preexisting code path that ever passes a null? If not I don't think this check is necessary.

I opted to be more safe than sorry. Since this is on the failure-path it isn't performance critical so I think affording a null-check is fine.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18988#discussion_r1583299298


More information about the core-libs-dev mailing list