public byte[] getNextTag() {
        byte[] tagBytes = null;

        if (tagPool != null) {
            tagBytes = tagPool.pollFirst();
        }

        if (tagBytes == null) {
            long tag = nextTagId++;
            int size = encodingSize(tag);

            tagBytes = new byte[size];

            for (int i = 0; i < size; ++i) {
                tagBytes[size - 1 - i] = (byte) (tag >>> (i * 8));
            }
        }

        return tagBytes;
    }
@Test
    public void testNewTagsOnSuccessiveCheckouts() {
        AmqpTransferTagGenerator tagGen = new AmqpTransferTagGenerator(true);

        byte[] tag1 = tagGen.getNextTag();
        byte[] tag2 = tagGen.getNextTag();
        byte[] tag3 = tagGen.getNextTag();

        assertNotSame(tag1, tag2);
        assertNotSame(tag1, tag3);
        assertNotSame(tag3, tag2);

        assertFalse(Arrays.equals(tag1, tag2));
        assertFalse(Arrays.equals(tag1, tag3));
        assertFalse(Arrays.equals(tag3, tag2));
    }