code: private ResultItem pollResultItem(long timeout, boolean idle) {
      ResultItem result = getResult();
      if (result != null) {
        result.remainingIdleTimeout = timeout;
      }
  
      if (result == null && timeout > 0) {
        long start = System.currentTimeMillis();
        internalWait(timeout);
        long end = System.currentTimeMillis();
        result = getResult();
        if (result != null) {
          result.remainingIdleTimeout = timeout - (end - start);
          logger.finest("Remaining timeout: " + result.remainingIdleTimeout);
        }
      }
  
      if (result == null) {
        if (idle) {
          throw new ResponseNotReceivedException("No idle response in a timely fashion");
        } else {
          throw new ResponseNotReceivedException("No response in a timely fashion");
        }
      }
  
      return result;
    }
docs: Checks for a result item. <p/> If no result item is available this method will wait for timeout
  milliseconds and try again. If still no result if available then a ResponseNotReceivedException
  is thrown.
  
  @param timeout time in milliseconds to wait before retrying.
  @param idle    whether you are waiting for an Idle event. Changes error message.
  @return the result