Skip to content

Commit

Permalink
Merge branch 'refs/heads/fix/YamlIterator-not-mutable' into refactor/…
Browse files Browse the repository at this point in the history
…StreamReader
  • Loading branch information
aSemy committed May 11, 2024
2 parents 6d0a1b6 + b8c9da7 commit 2c391af
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 @@ -126,7 +126,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 @@ -140,8 +140,6 @@ class Load @JvmOverloads constructor(
val node = composer.next()
return constructor.constructSingleDocument(node)
}

override fun remove(): Unit = throw UnsupportedOperationException("Removing is not supported.")
}

@Deprecated("renamed", ReplaceWith("loadAll(yamlStream)"))
Expand Down
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 2c391af

Please sign in to comment.