RFR: JDK-8257401: Use switch expressions in jdk.internal.net.http and java.net.http [v2]

Patrick Concannon pconcannon at openjdk.java.net
Tue Dec 1 12:07:57 UTC 2020


On Mon, 30 Nov 2020 13:04:11 GMT, Kartik Ohri <github.com+27751938+amCap1712 at openjdk.org> wrote:

>> Hi!
>> Kindly review this patch to replace switch statements with switch expressions (where it makes sense) in the http client modules. The rationale is to improve readability of the code.
>> Regards,
>> Kartik
>
> Kartik Ohri has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.

src/java.net.http/share/classes/jdk/internal/net/http/frame/SettingsFrame.java line 74:

> 72: 
> 73:     private String name(int i) {
> 74:         return switch (i + 1) {

Hi Kartik. I think it would improve the readability for each of the switch/case expressions if you tab aligned each of the cases, and place the default case on its own line e.g.

   
        
        return switch (i + 1) {
            case HEADER_TABLE_SIZE      -> "HEADER_TABLE_SIZE";
            case ENABLE_PUSH            -> "ENABLE_PUSH";
            case MAX_CONCURRENT_STREAMS -> "MAX_CONCURRENT_STREAMS";
            case INITIAL_WINDOW_SIZE    -> "INITIAL_WINDOW_SIZE";
            case MAX_FRAME_SIZE         -> "MAX_FRAME_SIZE";
            case MAX_HEADER_LIST_SIZE   -> "MAX_HEADER_LIST_SIZE";

            default -> "unknown parameter";
        };

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

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



More information about the security-dev mailing list