diff --git a/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java b/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java index edf4431936..713422d44b 100644 --- a/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java +++ b/src/main/java/com/amazon/ion/impl/IonReaderTextSystemX.java @@ -606,9 +606,7 @@ public final String stringValue() load_or_cast_cached_value(AS_TYPE.string_value); String text = _v.getString(); if (text == null) { - assert _value_type == IonType.SYMBOL; int sid = _v.getInt(); - assert sid > 0; throw new UnknownSymbolException(sid); } return text; diff --git a/src/test/java/com/amazon/ion/streaming/ReaderTest.java b/src/test/java/com/amazon/ion/streaming/ReaderTest.java index 65eebcf87b..88ccc42f54 100644 --- a/src/test/java/com/amazon/ion/streaming/ReaderTest.java +++ b/src/test/java/com/amazon/ion/streaming/ReaderTest.java @@ -25,6 +25,7 @@ import com.amazon.ion.ReaderMaker; import com.amazon.ion.SymbolTable; import com.amazon.ion.SymbolToken; +import com.amazon.ion.UnknownSymbolException; import com.amazon.ion.junit.Injected.Inject; import com.amazon.ion.junit.IonAssert; import java.io.IOException; @@ -193,6 +194,14 @@ public void testStringValueOnNonText() } } + @Test + public void testStringValueOnSymbolWithUndefinedText() + { + read("$0"); + assertEquals(IonType.SYMBOL, in.next()); + assertThrows(UnknownSymbolException.class, () -> in.stringValue()); + } + @Test public void testSymbolValue() throws Exception