class Inventory {

  private final int inventorySize;
  private final List<Item> items;
  private final Lock lock;

  /**
   * Constructor.
   */
  public Inventory(int inventorySize) {
    this.inventorySize = inventorySize;
    this.items = new ArrayList<>(inventorySize);
    this.lock = new ReentrantLock();
  }

  /**
   * Add item.
   */
  public boolean addItem(Item item) {<FILL_FUNCTION_BODY>}

  /**
   * Get all the items in the inventory.
   *
   * @return All the items of the inventory, as an unmodifiable list
   */
  public final List<Item> getItems() {
    return List.copyOf(items);
  }

}

    if (items.size() < inventorySize) {
      lock.lock();
      try {
        if (items.size() < inventorySize) {
          items.add(item);
          var thread = Thread.currentThread();
          LOGGER.info("{}: items.size()={}, inventorySize={}", thread, items.size(), inventorySize);
          return true;
        }
      } finally {
        lock.unlock();
      }
    }
    return false;
  
<no_super_class>