@@ -142,7 +142,9 @@ public void setSendBufferSize(int size) throws SocketException {
142142 try {
143143 unixSocketChannel .setOption (java .net .StandardSocketOptions .SO_SNDBUF , size );
144144 } catch (IOException e ) {
145- throw new SocketException ("Failed to set send buffer size socket option" );
145+ SocketException se = new SocketException ("Failed to set send buffer size socket option" );
146+ se .initCause (e );
147+ throw se ;
146148 }
147149 }
148150
@@ -169,7 +171,9 @@ public void setReceiveBufferSize(int size) throws SocketException {
169171 try {
170172 unixSocketChannel .setOption (java .net .StandardSocketOptions .SO_RCVBUF , size );
171173 } catch (IOException e ) {
172- throw new SocketException ("Failed to set receive buffer size socket option" );
174+ SocketException se = new SocketException ("Failed to set receive buffer size socket option" );
175+ se .initCause (e );
176+ throw se ;
173177 }
174178 }
175179
@@ -339,18 +343,31 @@ public void close() throws IOException {
339343 if (isClosed ()) {
340344 return ;
341345 }
342- if (!isInputShutdown ()) {
343- shutdownInput ();
346+ // Ignore possible exceptions so that we continue closing the socket
347+ try {
348+ if (!isInputShutdown ()) {
349+ shutdownInput ();
350+ }
351+ } catch (IOException e ) {
344352 }
345- if (!isOutputShutdown ()) {
346- shutdownOutput ();
353+ try {
354+ if (!isOutputShutdown ()) {
355+ shutdownOutput ();
356+ }
357+ } catch (IOException e ) {
347358 }
348- if (selector != null ) {
349- selector .close ();
350- selector = null ;
359+ try {
360+ if (selector != null ) {
361+ selector .close ();
362+ selector = null ;
363+ }
364+ } catch (IOException e ) {
351365 }
352- if (unixSocketChannel != null ) {
353- unixSocketChannel .close ();
366+ try {
367+ if (unixSocketChannel != null ) {
368+ unixSocketChannel .close ();
369+ }
370+ } catch (IOException e ) {
354371 }
355372 closed = true ;
356373 }
0 commit comments