Skip to content

Commit 7f64021

Browse files
committed
...
1 parent bb32698 commit 7f64021

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ public AvroFactory() {
7474
super(new AvroFactoryBuilder(), false);
7575
_avroParserFeatures = DEFAULT_AVRO_PARSER_FEATURE_FLAGS;
7676
_avroGeneratorFeatures = DEFAULT_AVRO_GENERATOR_FEATURE_FLAGS;
77+
_useApacheLibDecoder = false;
7778
}
7879

7980
public AvroFactory(ObjectCodec oc)
8081
{
8182
super(oc);
8283
_avroParserFeatures = DEFAULT_AVRO_PARSER_FEATURE_FLAGS;
8384
_avroGeneratorFeatures = DEFAULT_AVRO_GENERATOR_FEATURE_FLAGS;
85+
_useApacheLibDecoder = false;
8486

8587
/* 04-Mar-2013, tatu: Content auto-closing is unfortunately a feature
8688
* that works poorly with Avro error reporting, and generally
@@ -96,6 +98,7 @@ protected AvroFactory(AvroFactory src, ObjectCodec oc)
9698
super(src, oc);
9799
_avroParserFeatures = src._avroParserFeatures;
98100
_avroGeneratorFeatures = src._avroGeneratorFeatures;
101+
_useApacheLibDecoder = src._useApacheLibDecoder;
99102
}
100103

101104
/**

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,31 @@
77
import org.apache.avro.io.DatumReader;
88

99
import com.fasterxml.jackson.databind.ObjectMapper;
10-
import com.fasterxml.jackson.dataformat.avro.apacheimpl.ApacheAvroFactory;
1110

1211
// for [dataformats-binary#15]
1312
public class FileFormatTest extends AvroTestBase
1413
{
1514
public void testFileFormatOutput() throws Exception
1615
{
17-
_testFileFormatOutput(new AvroFactory());
18-
_testFileFormatOutput(new ApacheAvroFactory());
16+
_testFileFormatOutput(true);
17+
_testFileFormatOutput(false);
1918
}
2019

21-
private void _testFileFormatOutput(AvroFactory af) throws Exception
20+
private void _testFileFormatOutput(boolean useApacheImpl) throws Exception
2221
{
2322
Employee empl = new Employee();
2423
empl.name = "Bobbee";
2524
empl.age = 39;
2625
empl.emails = new String[] { "[email protected]", "[email protected]" };
2726
empl.boss = null;
2827

28+
AvroFactory af = (useApacheImpl
29+
? AvroFactory.builderWithApacheDecoder()
30+
: AvroFactory.builderWithNativeDecoder())
31+
.enable(AvroGenerator.Feature.AVRO_FILE_OUTPUT)
32+
.build();
2933
ObjectMapper mapper = new ObjectMapper(af);
3034

31-
af.enable(AvroGenerator.Feature.AVRO_FILE_OUTPUT);
32-
3335
AvroSchema schema = getEmployeeSchema();
3436
byte[] bytes = mapper.writer(schema).writeValueAsBytes(empl);
3537

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ public void testParserDefaults() throws Exception
3333
{
3434
AvroParser p = AVRO_F.createParser(new byte[0]);
3535
assertTrue(p.isEnabled(AvroParser.Feature.AVRO_BUFFERING));
36-
p.disable(AvroParser.Feature.AVRO_BUFFERING);
36+
p.close();
37+
38+
AvroFactory f = AvroFactory.builder()
39+
.disable(AvroParser.Feature.AVRO_BUFFERING)
40+
.build();
41+
p = f.createParser(new byte[0]);
3742
assertFalse(p.isEnabled(AvroParser.Feature.AVRO_BUFFERING));
3843
try {
3944
p.setSchema(BOGUS_SCHEMA);
@@ -49,7 +54,12 @@ public void testGeneratorDefaults() throws Exception
4954
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
5055
AvroGenerator g = AVRO_F.createGenerator(bytes);
5156
assertTrue(g.isEnabled(AvroGenerator.Feature.AVRO_BUFFERING));
52-
g.disable(AvroGenerator.Feature.AVRO_BUFFERING);
57+
g.close();
58+
59+
AvroFactory f = AvroFactory.builder()
60+
.disable(AvroGenerator.Feature.AVRO_BUFFERING)
61+
.build();
62+
g = f.createGenerator(bytes);
5363
assertFalse(g.isEnabled(AvroGenerator.Feature.AVRO_BUFFERING));
5464

5565
try {
@@ -59,8 +69,6 @@ public void testGeneratorDefaults() throws Exception
5969
; // finel
6070
}
6171
g.close();
62-
63-
6472
}
6573

6674
/*

0 commit comments

Comments
 (0)