rantav/hector — Issue #365: Unexpected NoSuchElementException exception
Author: ash2k
Created: 2011-12-14 08:14:56+00:00
State: open

I've tried to do

```
MappedColumnFamilyResult result = template.queryColumns(keys, columnFamilyRowMapper);
if (!result.hasResults()) {
return Collections.emptyList();
}
```
with empty ```keys``` iterable but got:

```
java.util.NoSuchElementException: No more rows left on this HColumnFamily
at me.prettyprint.cassandra.service.template.ColumnFamilyResultWrapper.next(ColumnFamilyResultWrapper.java:105)
at me.prettyprint.cassandra.service.template.ColumnFamilyResultWrapper.(ColumnFamilyResultWrapper.java:41)
at me.prettyprint.cassandra.service.template.MappedColumnFamilyResultWrapper.(MappedColumnFamilyResultWrapper.java:19)
at me.prettyprint.cassandra.service.template.ThriftColumnFamilyTemplate.doExecuteMultigetSlice(ThriftColumnFamilyTemplate.java:57)
at me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.queryColumns(ColumnFamilyTemplate.java:184)
```
In my opinion this is not correct behavior. It should not throw exception. It just should return ```false``` on ```result.hasResults()```.

fix (have not checked):
In ```ColumnFamilyResultWrapper```'s contructor replace

```
next();
hasEntries = getColumnNames() != null && getColumnNames().size() > 0;
```
with

```
hasEntries = getColumnNames() != null && getColumnNames().size() > 0;
if (hasEntries) {
next();
}
```