Skip to content

Commit

Permalink
PDFBOX-4687: Iterator.next() methods should throw NoSuchElementExcept…
Browse files Browse the repository at this point in the history
…ion, as suggested by SonarCloud and Haris Adzemovic; closes #75

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1869762 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 13, 2019
1 parent 5d7d8dc commit 4f3da9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -200,6 +201,10 @@ public boolean hasNext()
@Override
public PDPage next()
{
if (!hasNext())
{
throw new NoSuchElementException();
}
COSDictionary next = queue.poll();

sanitizeType(next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
* Iterator over the linked list of {@link PDOutlineItem} siblings.
Expand Down Expand Up @@ -45,6 +46,10 @@ public boolean hasNext()
@Override
public PDOutlineItem next()
{
if (!hasNext())
{
throw new NoSuchElementException();
}
if (currentItem == null)
{
currentItem = startingItem;
Expand Down

0 comments on commit 4f3da9a

Please sign in to comment.