< prev index next >

src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java

Print this page
rev 48757 : [mq]: nio-cleanup

*** 1,7 **** /* ! * Copyright (c) 2000, 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 23,36 **** * questions. */ package sun.nio.ch; ! import java.io.*; ! import java.net.*; ! import java.nio.*; ! import java.nio.channels.*; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.util.concurrent.TimeUnit; // Make a socket channel look like a socket. --- 23,49 ---- * questions. */ package sun.nio.ch; ! import java.io.IOException; ! import java.io.InputStream; ! import java.io.OutputStream; ! import java.net.InetAddress; ! import java.net.InetSocketAddress; ! import java.net.Socket; ! import java.net.SocketAddress; ! import java.net.SocketException; ! import java.net.SocketImpl; ! import java.net.SocketOption; ! import java.net.SocketTimeoutException; ! import java.net.StandardSocketOptions; ! import java.nio.ByteBuffer; ! import java.nio.channels.Channels; ! import java.nio.channels.ClosedChannelException; ! import java.nio.channels.IllegalBlockingModeException; ! import java.nio.channels.SocketChannel; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.util.concurrent.TimeUnit; // Make a socket channel look like a socket.
*** 43,53 **** // // The methods in this class are defined in exactly the same order as in // java.net.Socket so as to simplify tracking future changes to that class. // ! public class SocketAdaptor extends Socket { // The channel being adapted private final SocketChannelImpl sc; --- 56,66 ---- // // The methods in this class are defined in exactly the same order as in // java.net.Socket so as to simplify tracking future changes to that class. // ! class SocketAdaptor extends Socket { // The channel being adapted private final SocketChannelImpl sc;
*** 87,97 **** synchronized (sc.blockingLock()) { if (!sc.isBlocking()) throw new IllegalBlockingModeException(); try { - if (timeout == 0) { sc.connect(remote); return; } --- 100,109 ----
*** 117,128 **** } catch (IOException x) { } throw new SocketTimeoutException(); } } } finally { ! if (sc.isOpen()) sc.configureBlocking(true); } } catch (Exception x) { Net.translateException(x, true); } --- 129,141 ---- } catch (IOException x) { } throw new SocketTimeoutException(); } } } finally { ! try { sc.configureBlocking(true); + } catch (ClosedChannelException e) { } } } catch (Exception x) { Net.translateException(x, true); }
*** 186,199 **** throws IOException { synchronized (sc.blockingLock()) { if (!sc.isBlocking()) throw new IllegalBlockingModeException(); if (timeout == 0) return sc.read(bb); - sc.configureBlocking(false); try { int n; if ((n = sc.read(bb)) != 0) return n; long timeoutNanos = --- 199,213 ---- throws IOException { synchronized (sc.blockingLock()) { if (!sc.isBlocking()) throw new IllegalBlockingModeException(); + if (timeout == 0) return sc.read(bb); + sc.configureBlocking(false); try { int n; if ((n = sc.read(bb)) != 0) return n; long timeoutNanos =
*** 211,224 **** timeoutNanos -= System.nanoTime() - startTime; if (timeoutNanos <= 0) throw new SocketTimeoutException(); } } finally { ! if (sc.isOpen()) sc.configureBlocking(true); } - } } } private InputStream socketInputStream = null; --- 225,238 ---- timeoutNanos -= System.nanoTime() - startTime; if (timeoutNanos <= 0) throw new SocketTimeoutException(); } } finally { ! try { sc.configureBlocking(true); + } catch (ClosedChannelException e) { } } } } } private InputStream socketInputStream = null;
< prev index next >