public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: PR 31302
@ 2007-03-28  1:00 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2007-03-28  1:00 UTC (permalink / raw)
  To: GCJ-patches

I'm checking this in on the trunk and the RH 4.1 branch.

This is the fix for PR 31302, from the PR.
It fixes a buglet in our SSL code that Andrew Overholt noticed while
testing Mylar, an Eclipse plugin.  Casey Marshall wrote the patch.

Tom

Index: ChangeLog
from  Casey Marshall  <csm@gnu.org>

	PR classpath/31302:
	* gnu/javax/net/ssl/provider/SSLSocketImpl.java (SSLSocketImpl):
	Always make a new socket.
	(bind, connect, getInetAddress, getLocalAddress, getPort,
	getLocalPort, getRemoteSocketAddress, getLocalSocketAddress,
	setTcpNoDelay, getTcpNoDelay, setSoLinger, getSoLinger,
	setOOBInline, getOOBInline, setSoTimeout, getSoTimeout,
	setSendBufferSize, getSendBufferSize, setReceiveBufferSize,
	getReceiveBufferSize, setKeepAlive, getKeepAlive, setTrafficClass,
	getTrafficClass, setReuseAddress, getReuseAddress, close,
	shutdownInput, shutdownOutput, isConnected, isBound, isClosed,
	isInputShutdown, isOutputShutdown): Always use
	'underlyingSocket'.

Index: gnu/javax/net/ssl/provider/SSLSocketImpl.java
===================================================================
--- gnu/javax/net/ssl/provider/SSLSocketImpl.java	(revision 123266)
+++ gnu/javax/net/ssl/provider/SSLSocketImpl.java	(working copy)
@@ -200,7 +200,7 @@
   
   public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port)
   {
-    this(contextImpl, host, port, null, false);
+    this(contextImpl, host, port, new Socket(), true);
   }
   
   public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port,
@@ -412,17 +412,8 @@
     ByteBuffer emptyBuffer = ByteBuffer.allocate(0);
     SSLEngineResult result = null;
     
-    DataInputStream sockIn = null;
-    if (underlyingSocket != null)
-      sockIn = new DataInputStream(underlyingSocket.getInputStream());
-    else
-      sockIn = new DataInputStream(super.getInputStream());
-
-    OutputStream sockOut = null;
-    if (underlyingSocket != null)
-      sockOut = underlyingSocket.getOutputStream();
-    else
-      sockOut = super.getOutputStream();
+    DataInputStream sockIn = new DataInputStream(underlyingSocket.getInputStream());
+    OutputStream sockOut = underlyingSocket.getOutputStream();
     
     try
       {
@@ -550,69 +541,48 @@
 
   @Override public void bind(SocketAddress bindpoint) throws IOException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.bind(bindpoint);
-    else
-      super.bind(bindpoint);
+    underlyingSocket.bind(bindpoint);
   }
   
   @Override public void connect(SocketAddress endpoint) throws IOException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.connect(endpoint);
-    else
-      super.connect(endpoint);
+    underlyingSocket.connect(endpoint);
   }
 
   @Override public void connect(SocketAddress endpoint, int timeout)
     throws IOException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.connect(endpoint, timeout);
-    else
-      super.connect(endpoint, timeout);
+    underlyingSocket.connect(endpoint, timeout);
   }
 
   @Override public InetAddress getInetAddress()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getInetAddress();
-    return super.getInetAddress();
+    return underlyingSocket.getInetAddress();
   }
   
   @Override public InetAddress getLocalAddress()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getLocalAddress();
-    return super.getLocalAddress();
+    return underlyingSocket.getLocalAddress();
   }
   
   @Override public int getPort()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getPort();
-    return super.getPort();
+    return underlyingSocket.getPort();
   }
 
   @Override public int getLocalPort()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getLocalPort();
-    return super.getLocalPort();
+    return underlyingSocket.getLocalPort();
   }
 
   @Override public SocketAddress getRemoteSocketAddress()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getRemoteSocketAddress();
-    return super.getRemoteSocketAddress();
+    return underlyingSocket.getRemoteSocketAddress();
   }
 
   public SocketAddress getLocalSocketAddress()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getLocalSocketAddress();
-    return super.getLocalSocketAddress();
+    return underlyingSocket.getLocalSocketAddress();
   }
 
   @Override public SocketChannel getChannel()
@@ -632,32 +602,22 @@
 
   @Override public void setTcpNoDelay(boolean on) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setTcpNoDelay(on);
-    else
-      super.setTcpNoDelay(on);
+    underlyingSocket.setTcpNoDelay(on);
   }
 
   @Override public boolean getTcpNoDelay() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getTcpNoDelay();
-    return super.getTcpNoDelay();
+    return underlyingSocket.getTcpNoDelay();
   }
 
   @Override public void setSoLinger(boolean on, int linger) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setSoLinger(on, linger);
-    else
-      super.setSoLinger(on, linger);
+    underlyingSocket.setSoLinger(on, linger);
   }
 
   public int getSoLinger() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getSoLinger();
-    return super.getSoLinger();
+    return underlyingSocket.getSoLinger();
   }
 
   @Override public void sendUrgentData(int x) throws IOException
@@ -667,167 +627,114 @@
 
   @Override public void setOOBInline(boolean on) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setOOBInline(on);
-    else
-      super.setOOBInline(on);
+    underlyingSocket.setOOBInline(on);
   }
 
   @Override public boolean getOOBInline() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getOOBInline();
-    return super.getOOBInline();
+    return underlyingSocket.getOOBInline();
   }
 
   @Override public void setSoTimeout(int timeout) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setSoTimeout(timeout);
-    else
-      super.setSoTimeout(timeout);
+    underlyingSocket.setSoTimeout(timeout);
   }
 
   @Override public int getSoTimeout() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getSoTimeout();
-    return super.getSoTimeout();
+    return underlyingSocket.getSoTimeout();
   }
 
   @Override public void setSendBufferSize(int size) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setSendBufferSize(size);
-    else
-      super.setSendBufferSize(size);
+    underlyingSocket.setSendBufferSize(size);
   }
 
   @Override public int getSendBufferSize() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getSendBufferSize();
-    return super.getSendBufferSize();
+    return underlyingSocket.getSendBufferSize();
   }
 
   @Override public void setReceiveBufferSize(int size) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setReceiveBufferSize(size);
-    else
-      underlyingSocket.setReceiveBufferSize(size);
+    underlyingSocket.setReceiveBufferSize(size);
   }
 
   @Override public int getReceiveBufferSize() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getReceiveBufferSize();
-    return super.getReceiveBufferSize();
+    return underlyingSocket.getReceiveBufferSize();
   }
 
   @Override public void setKeepAlive(boolean on) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setKeepAlive(on);
-    else
-      super.setKeepAlive(on);
+    underlyingSocket.setKeepAlive(on);
   }
 
   @Override public boolean getKeepAlive() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getKeepAlive();
-    return super.getKeepAlive();
+    return underlyingSocket.getKeepAlive();
   }
 
   @Override public void setTrafficClass(int tc) throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setTrafficClass(tc);
-    else
-      super.setTrafficClass(tc);
+    underlyingSocket.setTrafficClass(tc);
   }
 
   @Override public int getTrafficClass() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getTrafficClass();
-    return super.getTrafficClass();
+    return underlyingSocket.getTrafficClass();
   }
 
   @Override public void setReuseAddress(boolean reuseAddress)
     throws SocketException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.setReuseAddress(reuseAddress);
-    else
-      super.setReuseAddress(reuseAddress);
+    underlyingSocket.setReuseAddress(reuseAddress);
   }
 
   @Override public boolean getReuseAddress() throws SocketException
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.getReuseAddress();
-    return super.getReuseAddress();
+    return underlyingSocket.getReuseAddress();
   }
 
   @Override public void close() throws IOException
   {
     // XXX closure alerts.
-    if (underlyingSocket != null && autoClose)
+    if (autoClose)
       underlyingSocket.close();
-    else
-      super.close();
   }
 
   @Override public void shutdownInput() throws IOException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.shutdownInput();
-    else
-      super.shutdownInput();
+    underlyingSocket.shutdownInput();
   }
 
   @Override public void shutdownOutput() throws IOException
   {
-    if (underlyingSocket != null)
-      underlyingSocket.shutdownOutput();
-    else
-      super.shutdownOutput();
+    underlyingSocket.shutdownOutput();
   }
 
   @Override public boolean isConnected()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.isConnected();
-    return super.isConnected();
+    return underlyingSocket.isConnected();
   }
 
   @Override public boolean isBound()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.isBound();
-    return super.isBound();
+    return underlyingSocket.isBound();
   }
 
   @Override public boolean isClosed()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.isClosed();
-    return super.isClosed();
+    return underlyingSocket.isClosed();
   }
 
   @Override public boolean isInputShutdown()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.isInputShutdown();
-    return super.isInputShutdown();
+    return underlyingSocket.isInputShutdown();
   }
 
   @Override public boolean isOutputShutdown()
   {
-    if (underlyingSocket != null)
-      return underlyingSocket.isOutputShutdown();
-    return super.isOutputShutdown();
+    return underlyingSocket.isOutputShutdown();
   }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-28  1:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-28  1:00 Patch: FYI: PR 31302 Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).