code: public void setCapacity(long capacity) {
          if (capacity < MIN_HEADER_TABLE_SIZE || capacity > MAX_HEADER_TABLE_SIZE) {
              throw new IllegalArgumentException("capacity is invalid: " + capacity);
          }
          // initially capacity will be -1 so init won't return here
          if (this.capacity == capacity) {
              return;
          }
          this.capacity = capacity;
  
          if (capacity == 0) {
              clear();
          } else {
              // initially size will be 0 so remove won't be called
              while (size > capacity) {
                  remove();
              }
          }
  
          int maxEntries = (int) (capacity / HpackHeaderField.HEADER_ENTRY_OVERHEAD);
          if (capacity % HpackHeaderField.HEADER_ENTRY_OVERHEAD != 0) {
              maxEntries++;
          }
  
          // check if capacity change requires us to reallocate the array
          if (hpackHeaderFields != null && hpackHeaderFields.length == maxEntries) {
              return;
          }
  
          HpackHeaderField[] tmp = new HpackHeaderField[maxEntries];
  
          // initially length will be 0 so there will be no copy
          int len = length();
          int cursor = tail;
          for (int i = 0; i < len; i++) {
              HpackHeaderField entry = hpackHeaderFields[cursor++];
              tmp[i] = entry;
              if (cursor == hpackHeaderFields.length) {
                  cursor = 0;
              }
          }
  
          tail = 0;
          head = tail + len;
          hpackHeaderFields = tmp;
      }
docs: Set the maximum size of the dynamic table. Entries are evicted from the dynamic table until
  the size of the table is less than or equal to the maximum size.