Skip to content

Commit

Permalink
Update YamlIterator to implement Iterator, not MutableIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy committed May 11, 2024
1 parent a5c7e22 commit b8c9da7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Load @JvmOverloads constructor(
private class YamlIterator(
private val composer: Composer,
private val constructor: BaseConstructor,
) : MutableIterator<Any?> {
) : Iterator<Any?> {
private var composerInitiated = false
override fun hasNext(): Boolean {
composerInitiated = true
Expand All @@ -170,7 +170,5 @@ class Load @JvmOverloads constructor(
val node = composer.next()
return constructor.constructSingleDocument(node)
}

override fun remove(): Unit = throw UnsupportedOperationException("Removing is not supported.")
}
}
2 changes: 1 addition & 1 deletion src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ void loadAllFromStringWithUnsupportedOperationException() {
Iterable<Object> v = load.loadAllFromString("bbb");
UnsupportedOperationException exception =
assertThrows(UnsupportedOperationException.class, () -> v.iterator().remove());
assertEquals("Removing is not supported.", exception.getMessage());
assertEquals("Operation is not supported for read-only collection", exception.getMessage());
}
}

0 comments on commit b8c9da7

Please sign in to comment.