code: public RequestEvent waitRequest(long timeout) {
      initErrorInfo();
  
      synchronized (reqBlock) {
        if (reqEvents.isEmpty()) {
          try {
            LOG.trace("about to block, waiting");
            reqBlock.waitForEvent(timeout);
            LOG.trace("we've come out of the block");
          } catch (Exception ex) {
            setException(ex);
            setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
            setReturnCode(EXCEPTION_ENCOUNTERED);
            return null;
          }
        }
  
        LOG.trace("either we got the request, or timed out");
        if (reqEvents.isEmpty()) {
          setReturnCode(TIMEOUT_OCCURRED);
          setErrorMessage("The maximum amount of time to wait for a request message has elapsed.");
          return null;
        }
  
        return (RequestEvent) reqEvents.removeFirst();
      }
    }
docs: The waitRequest() method waits for a request addressed to this SipSession's URI to be received
  from the network. Call this method after calling the listenRequestMessage() method.
  
  This method blocks until one of the following occurs: 1) A javax.sip.RequestEvent is received,
  addressed to this URI. This is the object returned by this method. 2) The wait timeout period
  specified by the parameter to this method expires. Null is returned in this case. 3) An error
  occurs. Null is returned in this case.
  
  @param timeout The maximum amount of time to wait, in milliseconds. Use a value of 0 to wait
  indefinitely.
  @return A RequestEvent or null in the case of wait timeout or error. If null, call
  getReturnCode() and/or getErrorMessage() and, if applicable, getException() for further
  diagnostics.