RFR: 8277412: Use String.isBlank to simplify code in sun.net.www.protocol.mailto.Handler

Alan Bateman alanb at openjdk.java.net
Tue Dec 7 08:10:18 UTC 2021


On Fri, 12 Nov 2021 19:11:36 GMT, Andrey Turbanov <duke at openjdk.java.net> wrote:

> All this manually written code actually can be replaced with single String.isBlank() call.
> `file` variable is guaranteed to be non-null.

src/java.base/share/classes/sun/net/www/protocol/mailto/Handler.java line 125:

> 123:          * Let's just make sure we DO have an Email address in the URL.
> 124:          */
> 125:         if (file.isBlank())

The mail protocol handler is a legacy protocol handler and I don't know if there is good test coverage. The change proposed here changes the exception from RuntimeException to NPE when there isn't a file component in the URL. Neither is specified by URLStreamHandler.parseURL so I suspect there may be follow-on issues to clarify the spec on several points.

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

PR: https://git.openjdk.java.net/jdk/pull/6372


More information about the net-dev mailing list