Skip to content

Commit

Permalink
Merge branch '2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatu-at-datastax committed Apr 26, 2024
2 parents 986d064 + db82942 commit c4c9fe1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ public JsonToken nextToken() throws JacksonException
}
if (type == null) {
if (_streamReadContext.inRoot()) { // EOF?
close();
_currToken = null;
} else {
_streamReadContext = _streamReadContext.getParent();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tools.jackson.dataformat.ion.sequence;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import org.junit.Test;

import tools.jackson.databind.MappingIterator;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.SequenceWriter;
import tools.jackson.dataformat.ion.IonObjectMapper;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class MappingIteratorTest {

private static final ObjectMapper MAPPER = new IonObjectMapper();

@Test
public void testReadFromWrite() throws Exception {
final Object[] values = new String[]{"1", "2", "3", "4"};

// write
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try (SequenceWriter seq = MAPPER.writer().writeValues(out)) {
for (Object value : values) {
seq.write(value);
}
}

// read
final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
try (MappingIterator<Object> it = MAPPER.readerFor(Object.class).readValues(in)) {
for (Object value : values) {
assertTrue(it.hasNext());
assertTrue(it.hasNext()); // should not alter the iterator state
assertEquals(value, it.next());
}
assertFalse(it.hasNext());
}
}

@Test
public void testReadFromEmpty() throws Exception {
final ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
try (MappingIterator<Object> it = MAPPER.readerFor(Object.class).readValues(in)) {
assertFalse(it.hasNext());
}
}
}
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ Thomas de Lange (@thomasdelange5)
value overflow checks
(2.17.0)

Yoann Vernageau (@yvrng)
* Contributed #487 (ion): Don't close IonParser on EOF to be compatible with `MappingIterator`
when source is an empty `InputStream`
(2.17.1)

PJ Fanning (pjfanning@github)
* Contributed #484: Rework synchronization in `ProtobufMapper`
(2.18.0)
4 changes: 4 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Active maintainers:

2.17.1 (not yet released)

#487 (ion): Don't close IonParser on EOF to be compatible with `MappingIterator`
when source is an empty `InputStream`
(contributed by Yoann V)

#488 (ion): Upgrade `ion-java` to 1.11.7 (from 1.11.2)

2.17.0 (12-Mar-2024)
Expand Down

0 comments on commit c4c9fe1

Please sign in to comment.