I think that if the solution was any simpler it would have bit me.

Change ClosableIterator<T> to extend AutoCloseable as well as Iterator.
mark ClosableIterator.close() with an @Override annotation and done.

While Autoclosable throws an exception the ClosableIterator does not so the
try with resources works.

I tried this and then changed
FinderUtils.contains() to be coded as

@Override
        public boolean contains(TriplePattern pattern) {
            try (ClosableIterator<Triple> it = find(pattern))
            {
            return it.hasNext();
            }
        }

and the IDE (Eclipse) does not complain.  So I think it will just work.

Reply via email to