code: int keepaliveThreadRead(ReadStream is, long timeoutConn)
      throws IOException
    {
      if (isClosed()) {
        return -1;
      }
  
      int available = is.availableBuffer();
  
      if (available > 0) {
        return available;
      }
  
      long timeout = Math.min(getKeepaliveTimeout(), getSocketTimeout());
      
      if (timeoutConn > 0) {
        timeout = Math.min(timeout, timeoutConn);
      }
  
      // server/2l02
      int keepaliveThreadCount = _keepaliveThreadCount.incrementAndGet();
  
      // boolean isSelectManager = getServer().isSelectManagerEnabled();
  
      try {
        int result;
  
        if (isKeepaliveAsyncEnabled() && _pollManager != null) {
          timeout = Math.min(timeout, getBlockingTimeoutForPoll());
  
          if (keepaliveThreadCount > 32) {
            // throttle the thread keepalive when heavily loaded to save threads
            if (isAsyncThrottle()) {
              // when async throttle is active move the thread to async
              // immediately
              return 0;
            }
            else {
              timeout = Math.min(timeout, 100);
            }
          }
        }
  
        /*
        if (timeout < 0)
          timeout = 0;
          */
  
        if (timeout <= 0) {
          return 0;
        }
  
        _keepaliveThreadMeter.start();
  
        try {
          /*
          if (false && _keepaliveThreadCount.get() < 32) {
            // benchmark perf with memcache
            result = is.fillWithTimeout(-1);
          }
          */
  
          result = is.fillWithTimeout(timeout);
        } finally {
          _keepaliveThreadMeter.end();
        }
  
        if (isClosed()) {
          return -1;
        }
  
        return result;
      } catch (IOException e) {
        if (isClosed()) {
          log.log(Level.FINEST, e.toString(), e);
  
          return -1;
        }
  
        throw e;
      } finally {
        _keepaliveThreadCount.decrementAndGet();
      }
    }
docs: Reads data from a keepalive connection