void () { int[] bufferSizesToCheck = generateBufferSizesToCheck(); //intentionally request randomly to check different ordering: ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < bufferSizesToCheck.length * 2; i++) { int bufferSize = bufferSizesToCheck[rnd.nextInt(bufferSizesToCheck.length)]; ByteBuffer buffer = allocator.allocate(bufferSize); try { assertTrue( "Allocated buffer.capacity(=" + buffer.capacity() + ") must be <= twice requested size(=" + bufferSize + ")", buffer.capacity() <= bufferSize * 2 ); } finally { allocator.release(buffer); } } }