src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
changeset 50303 7164c3bb55df
parent 48051 0b42613e35bf
child 53419 eac105e3ec13
equal deleted inserted replaced
50302:fd2fccf3b079 50303:7164c3bb55df
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    26 
    26 
    27 import java.io.IOException;
    27 import java.io.IOException;
    28 import java.util.Set;
    28 import java.util.Set;
    29 import java.util.HashSet;
    29 import java.util.HashSet;
    30 import sun.net.ext.ExtendedSocketOptions;
    30 import sun.net.ext.ExtendedSocketOptions;
       
    31 import static sun.net.ext.ExtendedSocketOptions.SOCK_DGRAM;
    31 
    32 
    32 /*
    33 /*
    33  * On Unix systems we simply delegate to native methods.
    34  * On Unix systems we simply delegate to native methods.
    34  *
    35  *
    35  * @author Chris Hegarty
    36  * @author Chris Hegarty
    75         }
    76         }
    76     }
    77     }
    77 
    78 
    78     protected Set<SocketOption<?>> supportedOptions() {
    79     protected Set<SocketOption<?>> supportedOptions() {
    79         HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
    80         HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
    80         addExtSocketOptions(extendedOptions.options(), options);
    81         options.addAll(ExtendedSocketOptions.options(SOCK_DGRAM));
    81         return options;
    82         return options;
    82     }
       
    83 
       
    84     private void addExtSocketOptions(Set<SocketOption<?>> extOptions,
       
    85                                      Set<SocketOption<?>> options) {
       
    86         // TCP_QUICKACK is applicable for TCP Sockets only.
       
    87         extOptions.stream()
       
    88                 .filter((option) -> !option.name().equals("TCP_QUICKACK"))
       
    89                 .forEach((option) -> options.add(option));
       
    90     }
    83     }
    91 
    84 
    92     protected void socketSetOption(int opt, Object val) throws SocketException {
    85     protected void socketSetOption(int opt, Object val) throws SocketException {
    93         if (opt == SocketOptions.SO_REUSEPORT &&
    86         if (opt == SocketOptions.SO_REUSEPORT &&
    94             !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
    87             !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {