On Tue, 4 Aug 2026 11:54:30 GMT, Jaikiran Pai <[email protected]> wrote:

>> test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java
>>  line 565:
>> 
>>> 563:                 throw new IllegalArgumentException("underlying 
>>> exchange "
>>> 564:                         + this.exchange.getClass().getName() + " is 
>>> not of type: "
>>> 565:                         + exchgType);
>> 
>> You can also choose to simplify this as follows:
>> 
>> Suggestion:
>> 
>>                 exchgType.cast(exchange);
>> 
>> 
>> This performs all the necessary checks, plus a `ClassCastException` with a 
>> good message.
>
> My impression is that a `IllegalStateException` with an explicit message 
> might be more useful. But I don't have a strong preference to either, so if 
> you and others think `ClassCastException` would be better, I'll update 
> accordingly.

I'm fine with either way.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32173#discussion_r3712655554

Reply via email to