Source:
<code>public void run() { InputStream istream; try { boolean isNewSocket = false; if (socketFactory != null) { socket = socketFactory.createSocket(); } else if( socket == null ) { socket = new Socket( proxy ); isNewSocket = true; } else if( socket.isClosed() ) { throw new IOException(); } socket.setTcpNoDelay( isTcpNoDelay() ); socket.setReuseAddress( isReuseAddr() ); if( !socket.isBound() ) { socket.connect( new InetSocketAddress( uri.getHost(), getPort() ), connectTimeout ); } if (isNewSocket && "wss".equals( uri.getScheme())) { SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, null, null); SSLSocketFactory factory = sslContext.getSocketFactory(); socket = factory.createSocket(socket, uri.getHost(), getPort(), true); } istream = socket.getInputStream(); ostream = socket.getOutputStream(); sendHandshake(); } catch ( Exception e ) { onWebsocketError( engine, e ); engine.closeConnection( CloseFrame.NEVER_CONNECTED, e.getMessage() ); return; } catch (InternalError e) { if (e.getCause() instanceof InvocationTargetException && e.getCause().getCause() instanceof IOException) { IOException cause = (IOException) e.getCause().getCause(); onWebsocketError(engine, cause); engine.closeConnection(CloseFrame.NEVER_CONNECTED, cause.getMessage()); return; } <START> throw e; <END> } writeThread = new Thread( new WebsocketWriteThread(this) ); writeThread.start(); byte[] rawbuffer = new byte[ WebSocketImpl.RCVBUF ]; int readBytes; try { while ( !isClosing() && !isClosed() && ( readBytes = istream.read( rawbuffer ) ) != -1 ) { engine.decode( ByteBuffer.wrap( rawbuffer, 0, readBytes ) ); } engine.eot(); } catch ( IOException e ) { handleIOException(e); } catch ( RuntimeException e ) { onError( e ); engine.closeConnection( CloseFrame.ABNORMAL_CLOSE, e.getMessage() ); } connectReadThread = null; }</code><technical_language>re-throw InternalError instead of returning normally</technical_language>

Target:
public void run() { InputStream istream; try { boolean isNewSocket = false; if (socketFactory != null) { socket = socketFactory.createSocket(); } else if( socket == null ) { socket = new Socket( proxy ); isNewSocket = true; } else if( socket.isClosed() ) { throw new IOException(); } socket.setTcpNoDelay( isTcpNoDelay() ); socket.setReuseAddress( isReuseAddr() ); if (!socket.isBound()) { InetSocketAddress addr = new InetSocketAddress(dnsResolver.resolve(uri), this.getPort()); socket.connect(addr, connectTimeout); } if (isNewSocket && "wss".equals( uri.getScheme())) { SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, null, null); SSLSocketFactory factory = sslContext.getSocketFactory(); socket = factory.createSocket(socket, uri.getHost(), getPort(), true); } istream = socket.getInputStream(); ostream = socket.getOutputStream(); sendHandshake(); } catch ( Exception e ) { onWebsocketError( engine, e ); engine.closeConnection( CloseFrame.NEVER_CONNECTED, e.getMessage() ); return; } catch (InternalError e) { if (e.getCause() instanceof InvocationTargetException && e.getCause().getCause() instanceof IOException) { IOException cause = (IOException) e.getCause().getCause(); onWebsocketError(engine, cause); engine.closeConnection(CloseFrame.NEVER_CONNECTED, cause.getMessage()); return; } throw e; } writeThread = new Thread( new WebsocketWriteThread(this) ); writeThread.start(); byte[] rawbuffer = new byte[ WebSocketImpl.RCVBUF ]; int readBytes; try { while ( !isClosing() && !isClosed() && ( readBytes = istream.read( rawbuffer ) ) != -1 ) { engine.decode( ByteBuffer.wrap( rawbuffer, 0, readBytes ) ); } engine.eot(); } catch ( IOException e ) { handleIOException(e); } catch ( RuntimeException e ) { onError( e ); engine.closeConnection( CloseFrame.ABNORMAL_CLOSE, e.getMessage() ); } connectReadThread = null; }