< prev index next >

src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java

Print this page

        

*** 204,214 **** if (fd == null || !fd.valid()) throw new SocketException("socket closed"); if (option == SO_FLOW_SLA) { assert flowSupported; ! SocketFlow flow = checkValueType(value, option.type()); setFlowOption(fd, flow); } else if (option == TCP_QUICKACK) { setQuickAckOption(fd, (boolean) value); } else if (option == TCP_KEEPCOUNT) { setTcpkeepAliveProbes(fd, (Integer) value); --- 204,214 ---- if (fd == null || !fd.valid()) throw new SocketException("socket closed"); if (option == SO_FLOW_SLA) { assert flowSupported; ! SocketFlow flow = checkValueType(value, SocketFlow.class); setFlowOption(fd, flow); } else if (option == TCP_QUICKACK) { setQuickAckOption(fd, (boolean) value); } else if (option == TCP_KEEPCOUNT) { setTcpkeepAliveProbes(fd, (Integer) value);
*** 252,267 **** } }); } @SuppressWarnings("unchecked") ! private static <T> T checkValueType(Object value, Class<?> type) { if (!type.isAssignableFrom(value.getClass())) { String s = "Found: " + value.getClass() + ", Expected: " + type; throw new IllegalArgumentException(s); } ! return (T) value; } private static final JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess(); --- 252,267 ---- } }); } @SuppressWarnings("unchecked") ! private static <T, U extends T> U checkValueType(Object value, Class<T> type) { if (!type.isAssignableFrom(value.getClass())) { String s = "Found: " + value.getClass() + ", Expected: " + type; throw new IllegalArgumentException(s); } ! return (U) value; } private static final JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess();
< prev index next >