diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactory.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactory.java index 500528dc1..60d31b5eb 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactory.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactory.java @@ -28,13 +28,13 @@ public class AvroFactory * Bitfield (set of flags) of all parser features that are enabled * by default. */ - final static int DEFAULT_AVRO_PARSER_FEATURE_FLAGS = AvroParser.Feature.collectDefaults(); + final static int DEFAULT_AVRO_PARSER_FEATURE_FLAGS = AvroReadFeature.collectDefaults(); /** * Bitfield (set of flags) of all generator features that are enabled * by default. */ - final static int DEFAULT_AVRO_GENERATOR_FEATURE_FLAGS = AvroGenerator.Feature.collectDefaults(); + final static int DEFAULT_AVRO_GENERATOR_FEATURE_FLAGS = AvroWriteFeature.collectDefaults(); /* /********************************************************** @@ -188,14 +188,14 @@ public boolean canParseAsync() { /** * Checked whether specified parser feature is enabled. */ - public final boolean isEnabled(AvroParser.Feature f) { + public final boolean isEnabled(AvroReadFeature f) { return (_formatReadFeatures & f.getMask()) != 0; } /** * Check whether specified generator feature is enabled. */ - public final boolean isEnabled(AvroGenerator.Feature f) { + public final boolean isEnabled(AvroWriteFeature f) { return (_formatWriteFeatures & f.getMask()) != 0; } @@ -216,13 +216,13 @@ public boolean canUseSchema(FormatSchema schema) { } @Override - public Class getFormatReadFeatureType() { - return AvroParser.Feature.class; + public Class getFormatReadFeatureType() { + return AvroReadFeature.class; } @Override - public Class getFormatWriteFeatureType() { - return AvroGenerator.Feature.class; + public Class getFormatWriteFeatureType() { + return AvroWriteFeature.class; } /* diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactoryBuilder.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactoryBuilder.java index 7b7ceaf2e..964341797 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactoryBuilder.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroFactoryBuilder.java @@ -84,65 +84,65 @@ public AvroFactory build() { // // // Parser features - public AvroFactoryBuilder enable(AvroParser.Feature f) { + public AvroFactoryBuilder enable(AvroReadFeature f) { _formatReadFeatures |= f.getMask(); return _this(); } - public AvroFactoryBuilder enable(AvroParser.Feature first, AvroParser.Feature... other) { + public AvroFactoryBuilder enable(AvroReadFeature first, AvroReadFeature... other) { _formatReadFeatures |= first.getMask(); - for (AvroParser.Feature f : other) { + for (AvroReadFeature f : other) { _formatReadFeatures |= f.getMask(); } return _this(); } - public AvroFactoryBuilder disable(AvroParser.Feature f) { + public AvroFactoryBuilder disable(AvroReadFeature f) { _formatReadFeatures &= ~f.getMask(); return _this(); } - public AvroFactoryBuilder disable(AvroParser.Feature first, AvroParser.Feature... other) { + public AvroFactoryBuilder disable(AvroReadFeature first, AvroReadFeature... other) { _formatReadFeatures &= ~first.getMask(); - for (AvroParser.Feature f : other) { + for (AvroReadFeature f : other) { _formatReadFeatures &= ~f.getMask(); } return _this(); } - public AvroFactoryBuilder configure(AvroParser.Feature f, boolean state) { + public AvroFactoryBuilder configure(AvroReadFeature f, boolean state) { return state ? enable(f) : disable(f); } // // // Generator features - public AvroFactoryBuilder enable(AvroGenerator.Feature f) { + public AvroFactoryBuilder enable(AvroWriteFeature f) { _formatWriteFeatures |= f.getMask(); return _this(); } - public AvroFactoryBuilder enable(AvroGenerator.Feature first, AvroGenerator.Feature... other) { + public AvroFactoryBuilder enable(AvroWriteFeature first, AvroWriteFeature... other) { _formatWriteFeatures |= first.getMask(); - for (AvroGenerator.Feature f : other) { + for (AvroWriteFeature f : other) { _formatWriteFeatures |= f.getMask(); } return _this(); } - public AvroFactoryBuilder disable(AvroGenerator.Feature f) { + public AvroFactoryBuilder disable(AvroWriteFeature f) { _formatWriteFeatures &= ~f.getMask(); return _this(); } - public AvroFactoryBuilder disable(AvroGenerator.Feature first, AvroGenerator.Feature... other) { + public AvroFactoryBuilder disable(AvroWriteFeature first, AvroWriteFeature... other) { _formatWriteFeatures &= ~first.getMask(); - for (AvroGenerator.Feature f : other) { + for (AvroWriteFeature f : other) { _formatWriteFeatures &= ~f.getMask(); } return _this(); } - public AvroFactoryBuilder configure(AvroGenerator.Feature f, boolean state) { + public AvroFactoryBuilder configure(AvroWriteFeature f, boolean state) { return state ? enable(f) : disable(f); } } diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroGenerator.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroGenerator.java index f2609be62..f32458330 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroGenerator.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroGenerator.java @@ -20,79 +20,6 @@ public class AvroGenerator extends GeneratorBase { - /** - * Enumeration that defines all togglable features for Avro generators - */ - public enum Feature - implements FormatFeature - { - /** - * Feature that can be disabled to prevent Avro from buffering any more - * data then absolutely necessary. - * This affects buffering by underlying codec. - * Note that disabling buffer is likely to reduce performance if the underlying - * input/output is unbuffered. - *

- * Enabled by default to preserve the existing behavior. - */ - AVRO_BUFFERING(true), - - /** - * Feature that tells Avro to write data in file format (i.e. including the schema with the data) - * rather than the RPC format which is otherwise default - *

- * NOTE: reader-side will have to be aware of distinction as well, since possible inclusion - * of this header is not 100% reliably auto-detectable (while header has distinct marker, - * "raw" Avro content has no limitations and could theoretically have same pre-amble from data). - */ - AVRO_FILE_OUTPUT(false), - - /** - * Feature that enables addition of {@code null} as default value in generated schema - * when no real default value is defined and {@code null} is legal value for type - * (union type with {@code null} included). - *

- * Disabled by default. - * - * @since 3.0 - * - */ - ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA(false) - ; - - protected final boolean _defaultState; - protected final int _mask; - - /** - * Method that calculates bit set (flags) of all features that - * are enabled by default. - */ - public static int collectDefaults() - { - int flags = 0; - for (Feature f : values()) { - if (f.enabledByDefault()) { - flags |= f.getMask(); - } - } - return flags; - } - - private Feature(boolean defaultState) { - _defaultState = defaultState; - _mask = (1 << ordinal()); - } - - @Override - public boolean enabledByDefault() { return _defaultState; } - - @Override - public int getMask() { return _mask; } - - @Override - public boolean enabledIn(int flags) { return (flags & _mask) != 0; } - } - /* /********************************************************************** /* Configuration @@ -111,7 +38,7 @@ private Feature(boolean defaultState) { /** * Bit flag composed of bits that indicate which - * {@link AvroGenerator.Feature}s + * {@link AvroWriteFeature}s * are enabled. */ protected int _formatWriteFeatures; @@ -165,7 +92,7 @@ public AvroGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, _output = output; _streamWriteContext = AvroWriteContext.nullContext(); _apacheCodecRecycler = apacheCodecRecycler; - final boolean buffering = isEnabled(Feature.AVRO_BUFFERING); + final boolean buffering = isEnabled(AvroWriteFeature.AVRO_BUFFERING); BinaryEncoder encoderToReuse = apacheCodecRecycler.acquireEncoder(); _encoder = buffering ? ENCODER_FACTORY.binaryEncoder(output, encoderToReuse) @@ -247,21 +174,21 @@ public JacksonFeatureSet streamWriteCapabilities() { /********************************************************************** */ - public AvroGenerator enable(Feature f) { + public AvroGenerator enable(AvroWriteFeature f) { _formatWriteFeatures |= f.getMask(); return this; } - public AvroGenerator disable(Feature f) { + public AvroGenerator disable(AvroWriteFeature f) { _formatWriteFeatures &= ~f.getMask(); return this; } - public final boolean isEnabled(Feature f) { + public final boolean isEnabled(AvroWriteFeature f) { return (_formatWriteFeatures & f.getMask()) != 0; } - public AvroGenerator configure(Feature f, boolean state) { + public AvroGenerator configure(AvroWriteFeature f, boolean state) { if (state) { enable(f); } else { diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroMapper.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroMapper.java index 05b201fe8..337ab12b9 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroMapper.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroMapper.java @@ -67,21 +67,21 @@ protected MapperBuilderState _saveState() { /****************************************************************** */ - public Builder enable(AvroParser.Feature... features) { - for (AvroParser.Feature f : features) { + public Builder enable(AvroReadFeature... features) { + for (AvroReadFeature f : features) { _formatReadFeatures |= f.getMask(); } return this; } - public Builder disable(AvroParser.Feature... features) { - for (AvroParser.Feature f : features) { + public Builder disable(AvroReadFeature... features) { + for (AvroReadFeature f : features) { _formatReadFeatures &= ~f.getMask(); } return this; } - public Builder configure(AvroParser.Feature feature, boolean state) + public Builder configure(AvroReadFeature feature, boolean state) { if (state) { _formatReadFeatures |= feature.getMask(); @@ -91,21 +91,21 @@ public Builder configure(AvroParser.Feature feature, boolean state) return this; } - public Builder enable(AvroGenerator.Feature... features) { - for (AvroGenerator.Feature f : features) { + public Builder enable(AvroWriteFeature... features) { + for (AvroWriteFeature f : features) { _formatWriteFeatures |= f.getMask(); } return this; } - public Builder disable(AvroGenerator.Feature... features) { - for (AvroGenerator.Feature f : features) { + public Builder disable(AvroWriteFeature... features) { + for (AvroWriteFeature f : features) { _formatWriteFeatures &= ~f.getMask(); } return this; } - public Builder configure(AvroGenerator.Feature feature, boolean state) + public Builder configure(AvroWriteFeature feature, boolean state) { if (state) { _formatWriteFeatures |= feature.getMask(); diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java index f015bd120..0d9e9e67a 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java @@ -20,52 +20,6 @@ */ public abstract class AvroParser extends ParserBase { - /** - * Enumeration that defines all togglable features for Avro parsers. - */ - public enum Feature - implements FormatFeature - { - /** - * Feature that can be disabled to prevent Avro from buffering any more - * data then absolutely necessary. - *

- * Enabled by default to preserve the existing behavior. - */ - AVRO_BUFFERING(true) - ; - - final boolean _defaultState; - final int _mask; - - /** - * Method that calculates bit set (flags) of all features that - * are enabled by default. - */ - public static int collectDefaults() - { - int flags = 0; - for (Feature f : values()) { - if (f.enabledByDefault()) { - flags |= f.getMask(); - } - } - return flags; - } - - Feature(boolean defaultState) { - _defaultState = defaultState; - _mask = (1 << ordinal()); - } - - @Override - public boolean enabledByDefault() { return _defaultState; } - @Override - public int getMask() { return _mask; } - @Override - public boolean enabledIn(int flags) { return (flags & _mask) != 0; } - } - // @since 2.14 - require some overrides protected final static JacksonFeatureSet AVRO_READ_CAPABILITIES = DEFAULT_READ_CAPABILITIES.with(StreamReadCapability.EXACT_FLOATS); @@ -162,27 +116,27 @@ public JacksonFeatureSet streamReadCapabilities() { /** * Method for enabling specified Avro feature - * (check {@link Feature} for list of features) + * (check {@link AvroReadFeature} for list of features) */ - public JsonParser enable(AvroParser.Feature f) { + public JsonParser enable(AvroReadFeature f) { _formatFeatures |= f.getMask(); return this; } /** * Method for disabling specified Avro feature - * (check {@link Feature} for list of features) + * (check {@link AvroReadFeature} for list of features) */ - public JsonParser disable(AvroParser.Feature f) { + public JsonParser disable(AvroReadFeature f) { _formatFeatures &= ~f.getMask(); return this; } /** * Method for enabling or disabling specified Avro feature - * (check {@link Feature} for list of features) + * (check {@link AvroReadFeature} for list of features) */ - public JsonParser configure(AvroParser.Feature f, boolean state) + public JsonParser configure(AvroReadFeature f, boolean state) { if (state) { enable(f); @@ -193,10 +147,10 @@ public JsonParser configure(AvroParser.Feature f, boolean state) } /** - * Method for checking whether specified Avro {@link Feature} + * Method for checking whether specified Avro {@link AvroReadFeature} * is enabled. */ - public boolean isEnabled(AvroParser.Feature f) { + public boolean isEnabled(AvroReadFeature f) { return (_formatFeatures & f.getMask()) != 0; } diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroReadFeature.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroReadFeature.java new file mode 100644 index 000000000..5a1af1fcb --- /dev/null +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroReadFeature.java @@ -0,0 +1,51 @@ +package tools.jackson.dataformat.avro; + +import tools.jackson.core.FormatFeature; + +/** + * Enumeration that defines all togglable features for Avro parsers. + *

+ * NOTE: in Jackson 2.x this was named {@code AvroParser.Feature}. + */ +public enum AvroReadFeature + implements FormatFeature +{ + /** + * Feature that can be disabled to prevent Avro from buffering any more + * data then absolutely necessary. + *

+ * Enabled by default to preserve the existing behavior. + */ + AVRO_BUFFERING(true) + ; + + private final boolean _defaultState; + private final int _mask; + + /** + * Method that calculates bit set (flags) of all features that + * are enabled by default. + */ + public static int collectDefaults() + { + int flags = 0; + for (AvroReadFeature f : values()) { + if (f.enabledByDefault()) { + flags |= f.getMask(); + } + } + return flags; + } + + private AvroReadFeature(boolean defaultState) { + _defaultState = defaultState; + _mask = (1 << ordinal()); + } + + @Override + public boolean enabledByDefault() { return _defaultState; } + @Override + public int getMask() { return _mask; } + @Override + public boolean enabledIn(int flags) { return (flags & _mask) != 0; } +} diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroWriteFeature.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroWriteFeature.java new file mode 100644 index 000000000..32230eccd --- /dev/null +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroWriteFeature.java @@ -0,0 +1,78 @@ +package tools.jackson.dataformat.avro; + +import tools.jackson.core.FormatFeature; + +/** + * Enumeration that defines all togglable features for Avro generators + *

+ * NOTE: in Jackson 2.x this was named {@code AvroGenerator.Feature}. + */ +public enum AvroWriteFeature + implements FormatFeature +{ + /** + * Feature that can be disabled to prevent Avro from buffering any more + * data then absolutely necessary. + * This affects buffering by underlying codec. + * Note that disabling buffer is likely to reduce performance if the underlying + * input/output is unbuffered. + *

+ * Enabled by default to preserve the existing behavior. + */ + AVRO_BUFFERING(true), + + /** + * Feature that tells Avro to write data in file format (i.e. including the schema with the data) + * rather than the RPC format which is otherwise default + *

+ * NOTE: reader-side will have to be aware of distinction as well, since possible inclusion + * of this header is not 100% reliably auto-detectable (while header has distinct marker, + * "raw" Avro content has no limitations and could theoretically have same pre-amble from data). + */ + AVRO_FILE_OUTPUT(false), + + /** + * Feature that enables addition of {@code null} as default value in generated schema + * when no real default value is defined and {@code null} is legal value for type + * (union type with {@code null} included). + *

+ * Disabled by default. + * + * @since 3.0 + * + */ + ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA(false) + ; + + private final boolean _defaultState; + private final int _mask; + + /** + * Method that calculates bit set (flags) of all features that + * are enabled by default. + */ + public static int collectDefaults() + { + int flags = 0; + for (AvroWriteFeature f : values()) { + if (f.enabledByDefault()) { + flags |= f.getMask(); + } + } + return flags; + } + + private AvroWriteFeature(boolean defaultState) { + _defaultState = defaultState; + _mask = (1 << ordinal()); + } + + @Override + public boolean enabledByDefault() { return _defaultState; } + + @Override + public int getMask() { return _mask; } + + @Override + public boolean enabledIn(int flags) { return (flags & _mask) != 0; } +} diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java b/avro/src/main/java/tools/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java index 5b66f461c..ace5edb47 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/apacheimpl/ApacheAvroParserImpl.java @@ -10,6 +10,7 @@ import tools.jackson.core.*; import tools.jackson.core.io.IOContext; import tools.jackson.dataformat.avro.AvroSchema; +import tools.jackson.dataformat.avro.AvroReadFeature; import tools.jackson.dataformat.avro.deser.AvroParserImpl; /** @@ -95,7 +96,7 @@ public ApacheAvroParserImpl(ObjectReadContext readCtxt, IOContext ioCtxt, _bufferRecyclable = true; _apacheCodecRecycler = apacheCodecRecycler; - final boolean buffering = Feature.AVRO_BUFFERING.enabledIn(avroFeatures); + final boolean buffering = AvroReadFeature.AVRO_BUFFERING.enabledIn(avroFeatures); BinaryDecoder decoderToReuse = apacheCodecRecycler.acquireDecoder(); _decoder = buffering ? DECODER_FACTORY.binaryDecoder(in, decoderToReuse) diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/schema/RecordVisitor.java b/avro/src/main/java/tools/jackson/dataformat/avro/schema/RecordVisitor.java index 1b734471f..bc315c429 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/schema/RecordVisitor.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/schema/RecordVisitor.java @@ -17,7 +17,7 @@ import tools.jackson.databind.ser.BeanPropertyWriter; import tools.jackson.dataformat.avro.AvroFactory; import tools.jackson.dataformat.avro.AvroFixedSize; -import tools.jackson.dataformat.avro.AvroGenerator; +import tools.jackson.dataformat.avro.AvroWriteFeature; import tools.jackson.dataformat.avro.ser.CustomEncodingSerializer; public class RecordVisitor @@ -47,7 +47,7 @@ public RecordVisitor(SerializationContext p, JavaType type, VisitorFormatWrapper _visitorWrapper = visitorWrapper; AvroFactory avroFactory = (AvroFactory) p.tokenStreamFactory(); - _cfgAddNullDefaults = avroFactory.isEnabled(AvroGenerator.Feature.ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA); + _cfgAddNullDefaults = avroFactory.isEnabled(AvroWriteFeature.ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA); // Check if the schema for this record is overridden SerializationConfig config = p.getConfig(); diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/ser/RootContext.java b/avro/src/main/java/tools/jackson/dataformat/avro/ser/RootContext.java index e50807fe9..3dc8ce2df 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/ser/RootContext.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/ser/RootContext.java @@ -10,7 +10,7 @@ import org.apache.avro.io.DatumWriter; import tools.jackson.dataformat.avro.AvroGenerator; -import tools.jackson.dataformat.avro.AvroGenerator.Feature; +import tools.jackson.dataformat.avro.AvroWriteFeature; class RootContext extends AvroWriteContext @@ -104,7 +104,7 @@ public void complete() throws IOException { // 21-Feb-2017, tatu: As per [dataformats-binary#15], need to ensure schema gets // written, if using "File" format (not raw "rpc" one) - if (_generator.isEnabled(Feature.AVRO_FILE_OUTPUT)) { + if (_generator.isEnabled(AvroWriteFeature.AVRO_FILE_OUTPUT)) { OutputStream outputStream = (OutputStream) _generator.streamWriteOutputTarget(); DatumWriter datumWriter = new NonBSGenericDatumWriter<>(_schema); DataFileWriter dataFileWriter = new DataFileWriter<>(datumWriter); diff --git a/avro/src/test/java/tools/jackson/dataformat/avro/FileFormatTest.java b/avro/src/test/java/tools/jackson/dataformat/avro/FileFormatTest.java index fd257959f..bfbab8cec 100644 --- a/avro/src/test/java/tools/jackson/dataformat/avro/FileFormatTest.java +++ b/avro/src/test/java/tools/jackson/dataformat/avro/FileFormatTest.java @@ -26,7 +26,7 @@ private void _testFileFormatOutput(AvroFactory af) throws Exception empl.boss = null; ObjectMapper mapper = new ObjectMapper(af.rebuild() - .configure(AvroGenerator.Feature.AVRO_FILE_OUTPUT, true).build()); + .configure(AvroWriteFeature.AVRO_FILE_OUTPUT, true).build()); AvroSchema schema = getEmployeeSchema(); byte[] bytes = mapper.writer(schema).writeValueAsBytes(empl); diff --git a/avro/src/test/java/tools/jackson/dataformat/avro/MapperConfigTest.java b/avro/src/test/java/tools/jackson/dataformat/avro/MapperConfigTest.java index 38feafd88..dc02be654 100644 --- a/avro/src/test/java/tools/jackson/dataformat/avro/MapperConfigTest.java +++ b/avro/src/test/java/tools/jackson/dataformat/avro/MapperConfigTest.java @@ -28,9 +28,9 @@ public String getSchemaType() { public void testFactoryDefaults() throws Exception { - assertTrue(MAPPER.tokenStreamFactory().isEnabled(AvroParser.Feature.AVRO_BUFFERING)); + assertTrue(MAPPER.tokenStreamFactory().isEnabled(AvroReadFeature.AVRO_BUFFERING)); - assertTrue(MAPPER.tokenStreamFactory().isEnabled(AvroGenerator.Feature.AVRO_BUFFERING)); + assertTrue(MAPPER.tokenStreamFactory().isEnabled(AvroWriteFeature.AVRO_BUFFERING)); assertFalse(MAPPER.tokenStreamFactory().isEnabled(StreamWriteFeature.AUTO_CLOSE_CONTENT)); assertFalse(MAPPER.tokenStreamFactory().canUseSchema(BOGUS_SCHEMA)); @@ -39,14 +39,14 @@ public void testFactoryDefaults() throws Exception public void testParserDefaults() throws Exception { AvroParser p = (AvroParser) MAPPER.createParser(new byte[0]); - assertTrue(p.isEnabled(AvroParser.Feature.AVRO_BUFFERING)); + assertTrue(p.isEnabled(AvroReadFeature.AVRO_BUFFERING)); p.close(); AvroMapper mapper = AvroMapper.builder() - .disable(AvroParser.Feature.AVRO_BUFFERING) + .disable(AvroReadFeature.AVRO_BUFFERING) .build(); p = (AvroParser) mapper.createParser(new byte[0]); - assertFalse(p.isEnabled(AvroParser.Feature.AVRO_BUFFERING)); + assertFalse(p.isEnabled(AvroReadFeature.AVRO_BUFFERING)); // 15-Jan-2021, tatu: 2.14 added this setting, not enabled in // default set @@ -63,16 +63,16 @@ public void testGeneratorDefaults() throws Exception .writer() .with(schema) .createGenerator(bytes); - assertTrue(g.isEnabled(AvroGenerator.Feature.AVRO_BUFFERING)); + assertTrue(g.isEnabled(AvroWriteFeature.AVRO_BUFFERING)); g.close(); AvroMapper mapper = AvroMapper.builder() - .disable(AvroGenerator.Feature.AVRO_BUFFERING) + .disable(AvroWriteFeature.AVRO_BUFFERING) .build(); g = (AvroGenerator) mapper.writer() .with(schema) .createGenerator(bytes); - assertFalse(g.isEnabled(AvroGenerator.Feature.AVRO_BUFFERING)); + assertFalse(g.isEnabled(AvroWriteFeature.AVRO_BUFFERING)); g.close(); } diff --git a/avro/src/test/java/tools/jackson/dataformat/avro/failing/FileSerialization319Test.java b/avro/src/test/java/tools/jackson/dataformat/avro/failing/FileSerialization319Test.java index 48e660b2c..742171eab 100644 --- a/avro/src/test/java/tools/jackson/dataformat/avro/failing/FileSerialization319Test.java +++ b/avro/src/test/java/tools/jackson/dataformat/avro/failing/FileSerialization319Test.java @@ -26,7 +26,7 @@ public void testFileSerialization() throws Exception employee.emails = new String[]{"bob@aol.com", "bobby@gmail.com"}; employee.boss = null; - final AvroFactory avroFactory = AvroFactory.builderWithApacheDecoder().enable(AvroGenerator.Feature.AVRO_FILE_OUTPUT).build(); + final AvroFactory avroFactory = AvroFactory.builderWithApacheDecoder().enable(AvroWriteFeature.AVRO_FILE_OUTPUT).build(); final AvroSchemaGenerator generator = new AvroSchemaGenerator(); final AvroMapper mapper = AvroMapper.builder(avroFactory).build(); diff --git a/avro/src/test/java/tools/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java b/avro/src/test/java/tools/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java index 66d080122..513c404e8 100644 --- a/avro/src/test/java/tools/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java +++ b/avro/src/test/java/tools/jackson/dataformat/avro/schema/AvroSchemaGenerationTest.java @@ -228,7 +228,7 @@ public void testDefaultValues() public void testEnabledDefaultValues() { AvroMapper mapper = new AvroMapper(AvroFactory.builder() - .enable(AvroGenerator.Feature.ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA) + .enable(AvroWriteFeature.ADD_NULL_AS_DEFAULT_VALUE_IN_SCHEMA) .build()); AvroSchemaGenerator gen = new AvroSchemaGenerator(); mapper.acceptJsonFormatVisitor(WithDefaults.class, gen); diff --git a/release-notes/VERSION b/release-notes/VERSION index 119f945da..01a31b5c0 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -20,3 +20,5 @@ implementations) adding default `null` in generated schema (contributed by kucera-jan-cz@github) #245: (ion) Pretty-printing not working Ion/text backend +#522: JSTEP-8: rename `AvroParser.Feature` as `AvroReadFeature`, + `AvroGenerator.Feature` as `AvroWriteFeature`