File tree Expand file tree Collapse file tree
main/java/com/jsoniter/any
test/java/com/jsoniter/any Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,9 +202,16 @@ public boolean hasNext() {
202202
203203 @ Override
204204 public Any next () {
205+ if (next == null ) {
206+ throw new IndexOutOfBoundsException ();
207+ }
205208 Any current = next ;
206- index ++;
207- next = fillCacheUntil (index );
209+ try {
210+ index ++;
211+ next = fillCacheUntil (index );
212+ } catch (IndexOutOfBoundsException e ){
213+ next = null ;
214+ }
208215 return current ;
209216 }
210217 }
Original file line number Diff line number Diff line change @@ -60,5 +60,7 @@ public void test_fill_partial_then_iterate() {
6060 Iterator <Any > iter = obj .iterator ();
6161 assertEquals (1 , iter .next ().toInt ());
6262 assertEquals (2 , iter .next ().toInt ());
63+ assertEquals (3 , iter .next ().toInt ());
64+ assertFalse (iter .hasNext ());
6365 }
6466}
You can’t perform that action at this time.
0 commit comments