Iterable<String> (final @NotNull LookupElement element) { return new Iterable<>() { @Override public @NotNull Iterator<String> iterator() { final Iterator<String> original = element.getAllLookupStrings().iterator(); return new UnmodifiableIterator<>(original) { @Override public boolean hasNext() { try { return super.hasNext(); } catch (ConcurrentModificationException e) { throw handleCME(e); } } @Override public String next() { try { return super.next(); } catch (ConcurrentModificationException e) { throw handleCME(e); } } private RuntimeException handleCME(ConcurrentModificationException cme) { RuntimeExceptionWithAttachments ewa = new RuntimeExceptionWithAttachments( "Error while traversing lookup strings of " + element + " of " + element.getClass(), (String)null, new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString())); ewa.initCause(cme); return ewa; } }; } }; }