public int getAndIncrementAtomicInt(final String path) throws InterruptedException, KeeperException {
        Stat stat = new Stat();
        while (true) {
            byte[] data;
            try {
                data = super.getData(path, false, stat);
            } catch (KeeperException e) {
                throw e;
            }
            assert (data.length == 4);
            final int oldValue = ByteConverter.getIntValue(data);
            data = ByteConverter.getByteArrayOfInt(oldValue + 1);
            try {
                super.setData(path, data, stat.getVersion());
            } catch (KeeperException e) {
                if (e.code() == Code.BADVERSION) {
                    continue;
                } else {
                    throw e;
                }
            }
            return oldValue;
        }
    }