diff -r d70fc9bc1430 -r bb5198288772 src/java.base/share/classes/java/net/SocketImpl.java --- a/src/java.base/share/classes/java/net/SocketImpl.java Mon Mar 11 19:53:08 2019 +0000 +++ b/src/java.base/share/classes/java/net/SocketImpl.java Tue Mar 12 09:49:10 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -204,6 +204,15 @@ protected abstract void close() throws IOException; /** + * Closes this socket, ignoring any IOException that is thrown by close. + */ + void closeQuietly() { + try { + close(); + } catch (IOException ignore) { } + } + + /** * Places the input stream for this socket at "end of stream". * Any data sent to this socket is acknowledged and then * silently discarded. @@ -470,6 +479,19 @@ } } + /** + * Attempts to copy socket options from this SocketImpl to a target SocketImpl. + * At this time, only the SO_TIMEOUT make sense to copy. + */ + void copyOptionsTo(SocketImpl target) { + try { + Object timeout = getOption(SocketOptions.SO_TIMEOUT); + if (timeout instanceof Integer) { + target.setOption(SocketOptions.SO_TIMEOUT, timeout); + } + } catch (IOException ignore) { } + } + private static final Set> socketOptions; private static final Set> serverSocketOptions;