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

Roger Riggs rriggs at openjdk.org
Fri Aug 5 16:48:26 UTC 2022


On Fri, 5 Aug 2022 15:07:17 GMT, thyecust <duke at openjdk.org> wrote:

>> The condition at line 57 (after while) will evaluate to false
>> if startLine == null, so the previous if-condition is covered.
>
> thyecust has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Merge branch 'openjdk:master' into if
>  - Merge branch 'openjdk:master' into if
>  - update the Copyright year
>  - simplify loop contidition
>  - Merge branch 'openjdk:master' into if
>  - remove redundant if-condition after readLine()
>    
>    The condition at line 57 (after while) will evaluate to false
>    if startLine == null, so the previous if-condition is covered.

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));`

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

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


More information about the net-dev mailing list