RFR [9] 8075139: Restore java.protocol.handler.pkgs to work as a fallback for migration

Chris Hegarty chris.hegarty at oracle.com
Wed Apr 15 14:35:49 UTC 2015


On 15/04/15 15:16, Paul Sandoz wrote:
> On Apr 15, 2015, at 1:36 PM, Chris Hegarty <chris.hegarty at oracle.com> wrote:
>>
>> Paul,
>>
>>>
>>> Yes, one could use a Pattern.splitAsStream, sorry could not resist :-) assuming this area is not sensitive to bootstrap issues e.g.
>>>
>>>     hander = p.splitAsStream().map(String::trim).flatMap(this::getHandler).findFirst().orElse(null);
>>
>> With the restriction we now have on overriding "core" protocol handlers we can actually use lambda's in this specific code path. I built a webrev based on your suggestion. Not too bad. I marginally favor this over webrev.01 above.
>>
>> http://cr.openjdk.java.net/~chegar/8075139/webrev.02/src/java.base/share/classes/java/net/URL.java.sdiff.html
>>
>
> Looks ok.
>
> I marginally prefer using flatMap rather than map/filter e.g. change getHandler to return Stream< URLStreamHandler> and change the last line to be "return Stream.ofNullable(handle). Up to you.

That's better. For completeness, the updated webrev:
   http://cr.openjdk.java.net/~chegar/8075139/webrev.03/

-Chris.

> If you stick with what you have perhaps consider changing "h -> h != null" to "Objects::nonNull".
>
> Paul.
>


More information about the net-dev mailing list