diff --git a/src/com/amazon/ion/impl/IonCursorBinary.java b/src/com/amazon/ion/impl/IonCursorBinary.java index 07e89cdb0f..811afbfd42 100644 --- a/src/com/amazon/ion/impl/IonCursorBinary.java +++ b/src/com/amazon/ion/impl/IonCursorBinary.java @@ -1808,7 +1808,9 @@ void slice(long offset, long limit, String ionVersionId) { valueMarker.endIndex = -1; event = Event.NEEDS_DATA; valueTid = null; - containerIndex = -1; // Slices are treated as if they were at the top level. + // Slices are treated as if they were at the top level. + parent = null; + containerIndex = -1; if (SystemSymbols.ION_1_0.equals(ionVersionId)) { typeIds = IonTypeID.TYPE_IDS_1_0; majorVersion = 1; diff --git a/test/com/amazon/ion/streaming/SeekableReaderTest.java b/test/com/amazon/ion/streaming/SeekableReaderTest.java index 066249d386..95992ac0f9 100644 --- a/test/com/amazon/ion/streaming/SeekableReaderTest.java +++ b/test/com/amazon/ion/streaming/SeekableReaderTest.java @@ -263,6 +263,29 @@ public void testHoistingAnnotatedContainedValue() expectTopEof(); } + @Test + public void testHoistingNestedContainerWithoutSteppingOutOfParent() + { + read("{first: {foo: bar}, second: a::{baz: zar}, third: 123}"); + in.next(); + in.stepIn(); + in.next(); + in.next(); + Span span = sr.currentSpan(); + in.next(); + // Note: we do not step out of the struct. + + hoist(span); + assertSame(IonType.STRUCT, in.next()); + expectTopLevel(); + Assert.assertArrayEquals(new String[]{"a"}, in.getTypeAnnotations()); + in.stepIn(); + in.next(); + assertEquals("zar", in.stringValue()); + in.stepOut(); + expectTopEof(); + } + @Test public void testHoistingAcrossSymbolTableBoundary() throws IOException