From b8c9da74938655820d345616e62292201fea8112 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Sat, 11 May 2024 20:20:28 +0200 Subject: [PATCH] Update YamlIterator to implement Iterator, not MutableIterator --- .../java/it/krzeminski/snakeyaml/engine/kmp/api/Load.kt | 4 +--- src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/jvmMain/java/it/krzeminski/snakeyaml/engine/kmp/api/Load.kt b/src/jvmMain/java/it/krzeminski/snakeyaml/engine/kmp/api/Load.kt index 78b0b3c3f..7f6e04ca7 100644 --- a/src/jvmMain/java/it/krzeminski/snakeyaml/engine/kmp/api/Load.kt +++ b/src/jvmMain/java/it/krzeminski/snakeyaml/engine/kmp/api/Load.kt @@ -156,7 +156,7 @@ class Load @JvmOverloads constructor( private class YamlIterator( private val composer: Composer, private val constructor: BaseConstructor, - ) : MutableIterator { + ) : Iterator { private var composerInitiated = false override fun hasNext(): Boolean { composerInitiated = true @@ -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.") } } diff --git a/src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java b/src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java index 67547df85..c8279ce9e 100644 --- a/src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java +++ b/src/jvmTest/java/org/snakeyaml/engine/v2/api/LoadTest.java @@ -197,6 +197,6 @@ void loadAllFromStringWithUnsupportedOperationException() { Iterable 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()); } }