You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/06/20 19:19:07 UTC
svn commit: r1352213 -
/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
Author: tn
Date: Wed Jun 20 17:19:07 2012
New Revision: 1352213
URL: http://svn.apache.org/viewvc?rev=1352213&view=rev
Log:
[COLLECTIONS-399] added more context information when throwing a NoSuchElementException.
Modified:
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java?rev=1352213&r1=1352212&r2=1352213&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java Wed Jun 20 17:19:07 2012
@@ -277,8 +277,11 @@ public class BoundedFifoBuffer<E> extend
* @throws NoSuchElementException if the requested position is outside the range [0, size)
*/
public E get(int index) {
- if (index < 0 || index >= size()) {
- throw new NoSuchElementException();
+ final int sz = size();
+ if (index < 0 || index >= sz) {
+ throw new NoSuchElementException(
+ String.format("The specified index (%1$d) is outside the available range [0, %2$d)",
+ index, sz));
}
final int idx = (start + index) % maxElements;