Skip to content

Commit 7172e68

Browse files
committed
Merge branch '3.1' into 3.x
2 parents 6e62c7a + 24e487f commit 7172e68

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

ion/src/main/java/tools/jackson/dataformat/ion/IonFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ private JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt,
482482
protected IonGenerator _createGenerator(ObjectWriteContext writeCtxt,
483483
OutputStream out, JsonEncoding enc, boolean isManaged)
484484
{
485-
IonWriter ion;
486485
IOContext ioCtxt = _createContext(_createContentReference(out), isManaged);
487-
Closeable dst; // not necessarily same as 'out'...
486+
final IonWriter ion;
487+
final Closeable dst; // not necessarily same as 'out'...
488488

489489
// Binary writers are simpler: no alternate encodings
490490
if (_cfgBinaryWriters) {

ion/src/test/java/tools/jackson/dataformat/ion/PrettyPrintWriteTest.java renamed to ion/src/test/java/tools/jackson/dataformat/ion/IonPrettyPrintWriteTest.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,46 @@
1010
import static org.junit.jupiter.api.Assertions.assertNotNull;
1111

1212
// For [dataformats-binary#245]: no pretty-printing for textual format
13-
public class PrettyPrintWriteTest
13+
public class IonPrettyPrintWriteTest
1414
{
1515
@JsonPropertyOrder({ "x", "y" })
1616
static class Point {
1717
public int x = 1;
1818
public int y = 2;
1919
}
2020

21+
private final IonObjectMapper TEXTUAL_MAPPER = IonObjectMapper.builder(IonFactory.forTextualWriters()).build();
22+
2123
@Test
22-
public void testBasicPrettyPrintTextual() throws Exception
24+
public void prettyPrintTextual() throws Exception
2325
{
2426
final String EXP = "{\n x:1,\n y:2\n}";
2527

26-
IonObjectMapper mapper = IonObjectMapper.builder(IonFactory.forTextualWriters()).build();
27-
String ion = mapper.writerWithDefaultPrettyPrinter()
28+
String ion = TEXTUAL_MAPPER.writerWithDefaultPrettyPrinter()
2829
.writeValueAsString(new Point());
2930
assertEquals(EXP, ion.trim());
3031

31-
ion = mapper.writer()
32+
ion = TEXTUAL_MAPPER.writer()
3233
.with(SerializationFeature.INDENT_OUTPUT)
3334
.writeValueAsString(new Point());
3435
assertEquals(EXP, ion.trim());
3536

37+
IonObjectMapper mapper = TEXTUAL_MAPPER.rebuild()
38+
.enable(SerializationFeature.INDENT_OUTPUT)
39+
.build();
40+
ion = mapper.writeValueAsString(new Point());
41+
assertEquals(EXP, ion.trim());
42+
3643
// But also no indentation if not requested
3744
ion = mapper.writer()
45+
.without(SerializationFeature.INDENT_OUTPUT)
3846
.writeValueAsString(new Point());
3947
assertEquals("{x:1,y:2}", ion.trim());
4048
}
4149

4250
// and with binary format, should simply be no-op
4351
@Test
44-
public void testIgnorePrettyPrintForBinary() throws Exception
52+
public void prettyPrintIgnoredForBinary() throws Exception
4553
{
4654
IonObjectMapper mapper = IonObjectMapper.builder(IonFactory.forBinaryWriters()).build();
4755
byte[] encoded = mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(new Point());

smile/src/test/java/tools/jackson/dataformat/smile/BaseTestForSmile.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ public static IOContext testIOContext() {
207207
protected JsonParser createParserUsingStream(TokenStreamFactory f, byte[] input)
208208
throws IOException
209209
{
210-
return f.createParser(new ByteArrayInputStream(input));
210+
return f.createParser(ObjectReadContext.empty(),
211+
new ByteArrayInputStream(input));
211212
}
212213

213214
/*

0 commit comments

Comments
 (0)