HttpClient API usage feedback/questions

Jaikiran Pai jai.forums2013 at gmail.com
Sun Jun 3 01:49:40 UTC 2018


You are right. That didn't occur to me. So yes, clearly, adding those 2 new
methods won't add value.

-Jaikiran

On Sunday, June 3, 2018, Pavel Rappo <pavel.rappo at oracle.com> wrote:
>
>> On 2 Jun 2018, at 07:22, Jaikiran Pai <jai.forums2013 at gmail.com> wrote:
>>
>> Some of the places where we parse the (response) headers, we check for
the presence of some headers and if not present then we default them to
certain values (based on certain application specific context). In its
current form of the HttpHeaders API, we would either have to write some
kind of wrapper API which returns a default value for those headers or keep
repeating the logic of checking the returned Optional for empty value,
before defaulting it to something.
>
> Probably asking the obvious, but why can't you just write:
>
>     headers.firstValue(name).orElse(defaultValue)
>
> instead of
>
>     headers.firstValueOrDefault(name, defaultValue) ?
>
> I'm not sure the value provided by introducing these methods is worth the
> increase in this API's size. Optionals provide a toolset for such tasks.
> This toolset is much richer than just "defaulting".
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20180603/dce6625b/attachment.html>


More information about the net-dev mailing list