RFR: 8291956: Simplify the loop condition in sun.net.httpserver.Request constructor [v4]

Daniel Fuchs dfuchs at openjdk.org
Fri Aug 5 17:25:14 UTC 2022


On Fri, 5 Aug 2022 17:21:28 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> src/jdk.httpserver/share/classes/sun/net/httpserver/Request.java line 54:
>> 
>>> 52:             startLine = readLine();
>>> 53:             /* skip blank lines */
>>> 54:         } while (startLine != null && startLine.equals (""));
>> 
>> Drive-by comment;  Swapping the arguments for String.equals will handle the case of startLine == null.
>> `} while ("".equals(startLine));`
>
> Right - which reminds me `String.equals("")` is an anti-pattern that should probably be replaced by `String.isEmpty()`

One or the other :-)

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

PR: https://git.openjdk.org/jdk/pull/9571


More information about the net-dev mailing list