DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Lists.transform() throws a NoSuchElementException if an IndexOutOfBoundsException is raised #1606

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
While a list transformation through Lists.transform(), if the transform 
function raises an IndexOutOfBoundsException, then a NoSuchElementException is 
thrown.
The main problem is that the IndexOutOfBoundsException will never appear in the 
NoSuchElementException stack trace, so the error source is hard to find.

The problem seems to only occur with IndexOutOfBoundsException. If a plain 
RuntimeException is thrown inside the transform function, the RuntimeException 
will correctly by thrown again by Lists.transform().

The problem is present at least in Guava 14 and 15.

Original issue reported on code.google.com by amante...@gmail.com on 9 Dec 2013 at 5:51

Attachments:

GoogleCodeExporter commented 9 years ago
Interestingly enough, the issue doesn't appear to come from Guava code -- it's 
java.util.AbstractList's implementation of Iterator that catches IOOBE and 
turns it into an NSEE.

I'll see what can be done.

Original comment by lowas...@google.com on 9 Dec 2013 at 7:59

GoogleCodeExporter commented 9 years ago
Fix submitted internally; will be mirrored out soon.

Original comment by lowas...@google.com on 9 Dec 2013 at 9:51

GoogleCodeExporter commented 9 years ago
Thanks, you were incredibly fast to solve this issue!

Original comment by amante...@gmail.com on 9 Dec 2013 at 10:30

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 19 Dec 2013 at 8:34

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08