@Override
  public void release(T item) {
    checkNotNull(item, "item");

    synchronized (createdItems) {
      if (!createdItems.contains(item)) {
        throw new IllegalArgumentException("This item is not a part of this pool");
      }
    }

    // Return if this item was released earlier.
    // We cannot use items.contains() because that check is not based on reference equality.
    for (T entry : items) {
      if (entry == item) {
        return;
      }
    }

    try {
      items.put(item);
    } catch (InterruptedException e) {
      throw new IllegalStateException("release() should never block", e);
    }
  }
@Test
  public void testArgChecks() throws Exception {

    // Should not throw.
    BufferPool pool = new BufferPool(5);

    // Verify it throws correctly.

    intercept(IllegalArgumentException.class,
        "'size' must be a positive integer",
        () -> new BufferPool(-1));

    intercept(IllegalArgumentException.class,
        "'size' must be a positive integer",
        () -> new BufferPool(0));

    intercept(IllegalArgumentException.class, "'item' must not be null",
        () -> pool.release(null));

    intercept(IllegalArgumentException.class,
        "This item is not a part of this pool",
        () -> pool.release(ByteBuffer.allocate(4)));

  }