#fixed code
                             protected final void interruptableRun() {
		try {
			tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
		} catch ( ClosedByInterruptException e ) {
			onWebsocketError( null, e );
			return;
		} catch ( IOException e ) {//
			onWebsocketError( conn, e );
			return;
		} catch ( SecurityException e ) {
			onWebsocketError( conn, e );
			return;
		} catch ( UnresolvedAddressException e ) {
			onWebsocketError( conn, e );
			return;
		}
		conn = (WebSocketImpl) wf.createWebSocket( this, draft, channel.socket() );
		ByteBuffer buff = ByteBuffer.allocate( WebSocket.RCVBUF );
		try/*IO*/{
			while ( !conn.isClosed() ) {
				if( Thread.interrupted() ) {
					conn.close( CloseFrame.NORMAL );
				}
				SelectionKey key = null;
				SocketChannelIOHelper.batch( conn, channel );
				selector.select();
				Set<SelectionKey> keys = selector.selectedKeys();
				Iterator<SelectionKey> i = keys.iterator();
				while ( i.hasNext() ) {
					key = i.next();
					i.remove();
					if( key.isReadable() && SocketChannelIOHelper.read( buff, this.conn, channel ) ) {
						conn.decode( buff );
					}
					if( !key.isValid() ) {
						continue;
					}
					if( key.isConnectable() ) {
						try {
							finishConnect();
						} catch ( InterruptedException e ) {
							conn.close( CloseFrame.NEVERCONNECTED );// report error to only
							break;
						} catch ( InvalidHandshakeException e ) {
							conn.close( e ); // http error
						}
					}
				}
			}
		} catch ( IOException e ) {
			onError( e );
			conn.close( CloseFrame.ABNORMAL_CLOSE );
		} catch ( RuntimeException e ) {
			// this catch case covers internal errors only and indicates a bug in this websocket implementation
			onError( e );
			conn.eot( e );
		}

		try {
			selector.close();
		} catch ( IOException e ) {
			onError( e );
		}
		closelock.lock();
		selector = null;
		closelock.unlock();
		try {
			channel.close();
		} catch ( IOException e ) {
			onError( e );
		}
		channel = null;
	}
#vulnerable code 
                             protected final void interruptableRun() {
		try {
			tryToConnect( new InetSocketAddress( uri.getHost(), getPort() ) );
		} catch ( ClosedByInterruptException e ) {
			onWebsocketError( null, e );
			return;
		} catch ( IOException e ) {//
			onWebsocketError( conn, e );
			return;
		} catch ( SecurityException e ) {
			onWebsocketError( conn, e );
			return;
		} catch ( UnresolvedAddressException e ) {
			onWebsocketError( conn, e );
			return;
		}
		conn = (WebSocketImpl) wf.createWebSocket( this, draft, client );
		ByteBuffer buff = ByteBuffer.allocate( WebSocket.RCVBUF );
		try/*IO*/{
			while ( !conn.isClosed() ) {
				if( Thread.interrupted() ) {
					conn.close( CloseFrame.NORMAL );
				}
				SelectionKey key = null;
				conn.flush();
				selector.select();
				Set<SelectionKey> keys = selector.selectedKeys();
				Iterator<SelectionKey> i = keys.iterator();
				while ( i.hasNext() ) {
					key = i.next();
					i.remove();
					if( key.isReadable() && conn.read( buff ) ) {
						conn.decode( buff );
					}
					if( !key.isValid() ) {
						continue;
					}
					if( key.isWritable() ) {
						conn.flush();
					}
					if( key.isConnectable() ) {
						try {
							finishConnect();
						} catch ( InterruptedException e ) {
							conn.close( CloseFrame.NEVERCONNECTED );// report error to only
							break;
						} catch ( InvalidHandshakeException e ) {
							conn.close( e ); // http error
							conn.flush();
						}
					}
				}
			}
		} catch ( IOException e ) {
			onError( e );
			conn.close( CloseFrame.ABNORMAL_CLOSE );
			return;
		} catch ( RuntimeException e ) {
			// this catch case covers internal errors only and indicates a bug in this websocket implementation
			onError( e );
			conn.closeConnection( CloseFrame.BUGGYCLOSE, e.toString(), false );
			return;
		}

		try {
			selector.close();
		} catch ( IOException e ) {
			onError( e );
		}
		closelock.lock();
		selector = null;
		closelock.unlock();
		try {
			client.close();
		} catch ( IOException e ) {
			onError( e );
		}
		client = null;
	} 
                            #location 25 
                            #vulnerability type THREAD_SAFETY_VIOLATION