use of java.util.NoSuchElementException in project groovy by apache.
the class EmptyRangeTest method testIterator.
/**
* Test method for {@link groovy.lang.EmptyRange#iterator()}.
*/
public void testIterator() {
final Iterator iterator = range.iterator();
assertFalse("iterator has next value", iterator.hasNext());
try {
iterator.next();
fail("got next value in an empty range");
} catch (NoSuchElementException e) {
assertTrue("expected exception thrown", true);
}
}
use of java.util.NoSuchElementException in project flink by apache.
the class DataSourceTask method getInputSplits.
private Iterator<InputSplit> getInputSplits() {
final InputSplitProvider provider = getEnvironment().getInputSplitProvider();
return new Iterator<InputSplit>() {
private InputSplit nextSplit;
private boolean exhausted;
@Override
public boolean hasNext() {
if (exhausted) {
return false;
}
if (nextSplit != null) {
return true;
}
final InputSplit split;
try {
split = provider.getNextInputSplit(getUserCodeClassLoader());
} catch (InputSplitProviderException e) {
throw new RuntimeException("Could not retrieve next input split.", e);
}
if (split != null) {
this.nextSplit = split;
return true;
} else {
exhausted = true;
return false;
}
}
@Override
public InputSplit next() {
if (this.nextSplit == null && !hasNext()) {
throw new NoSuchElementException();
}
final InputSplit tmp = this.nextSplit;
this.nextSplit = null;
return tmp;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
use of java.util.NoSuchElementException in project hadoop by apache.
the class CorruptFileBlockIterator method next.
@Override
public Path next() throws IOException {
if (!hasNext()) {
throw new NoSuchElementException("No more corrupt file blocks");
}
Path result = nextPath;
loadNext();
return result;
}
use of java.util.NoSuchElementException in project hbase by apache.
the class WALEntryStream method next.
/**
* @return the next WAL entry in this stream
* @throws WALEntryStreamRuntimeException if there was an IOException
* @throws NoSuchElementException if no more entries in the stream.
*/
@Override
public Entry next() {
if (!hasNext())
throw new NoSuchElementException();
Entry save = currentEntry;
// gets reloaded by hasNext()
currentEntry = null;
return save;
}
use of java.util.NoSuchElementException in project hbase by apache.
the class RowResultGenerator method next.
public Cell next() {
if (cache != null) {
Cell kv = cache;
cache = null;
return kv;
}
if (valuesI == null) {
return null;
}
try {
return valuesI.next();
} catch (NoSuchElementException e) {
return null;
}
}
Aggregations