OutbindRequest waitForRequest ( long timeout ) throws IllegalStateException , TimeoutException { this . lock . lock ( ) ; try { if ( this . alreadyWaitForRequest ) { throw new IllegalStateException ( "waitForRequest(long) method already invoked" ) ; } else if ( this . request == null ) { try { this . requestCondition . await ( timeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new RuntimeException ( "waitForRequest was interrupted" ) ; } } if ( this . request != null ) { return this . request ; } else { throw new TimeoutException ( "Waiting for outbind request take time too long" ) ; } } finally { this . alreadyWaitForRequest = true ; this . lock . unlock ( ) ; } }
Wait until the outbind request received for specified timeout .