From 653f792071300dc1a23368119097c8bcf5fe4377 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 2 Nov 2023 17:26:23 -0700 Subject: [PATCH] Merge a (small) subset of #409 into 2.16 (no point merging into 2.15) (#413) --- .../jackson/dataformat/avro/AvroGenerator.java | 13 +++++++------ .../jackson/dataformat/avro/AvroParser.java | 2 +- .../jackson/dataformat/avro/AvroSchema.java | 2 +- .../dataformat/avro/deser/AvroFieldDefaulters.java | 4 ++-- .../dataformat/avro/deser/AvroParserImpl.java | 7 ++++--- .../dataformat/avro/deser/AvroReaderFactory.java | 9 ++++----- .../avro/deser/JacksonAvroParserImpl.java | 4 ++-- .../dataformat/avro/schema/AvroSchemaHelper.java | 9 ++++----- .../dataformat/avro/schema/DefinedSchemas.java | 2 +- .../dataformat/avro/schema/RecordVisitor.java | 2 +- .../dataformat/avro/schema/SchemaBuilder.java | 2 +- .../avro/schema/VisitorFormatWrapperImpl.java | 12 ++---------- .../dataformat/avro/ser/AvroWriteContext.java | 2 +- .../dataformat/avro/ser/MapWriteContext.java | 2 +- .../jackson/dataformat/avro/ser/RootContext.java | 2 +- .../jackson/dataformat/avro/ArrayTest.java | 3 ++- .../jackson/dataformat/avro/AvroTestBase.java | 6 +++--- .../jackson/dataformat/avro/BinaryDataTest.java | 6 +++--- .../jackson/dataformat/avro/FileFormatTest.java | 4 ++-- .../jackson/dataformat/avro/Issue19Test.java | 4 ++-- .../fasterxml/jackson/dataformat/avro/MapTest.java | 4 ++-- .../jackson/dataformat/avro/MapWithUnionTest.java | 6 +++--- .../jackson/dataformat/avro/MapperConfigTest.java | 7 +------ .../jackson/dataformat/avro/RootSequenceTest.java | 6 +++--- .../fasterxml/jackson/dataformat/avro/UUIDTest.java | 3 ++- .../avro/interop/annotations/AvroAliasTest.java | 6 +++--- .../avro/interop/annotations/AvroEncodeTest.java | 2 +- 27 files changed, 60 insertions(+), 71 deletions(-) diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroGenerator.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroGenerator.java index 18e86c798..6024e0035 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroGenerator.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroGenerator.java @@ -4,6 +4,7 @@ import java.io.OutputStream; import java.math.BigDecimal; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import org.apache.avro.io.BinaryEncoder; import org.apache.avro.io.EncoderFactory; @@ -68,7 +69,7 @@ public static int collectDefaults() return flags; } - private Feature(boolean defaultState) { + Feature(boolean defaultState) { _defaultState = defaultState; _mask = (1 << ordinal()); } @@ -481,7 +482,7 @@ public void writeRawUTF8String(byte[] text, int offset, int len) throws IOExcept @Override public final void writeUTF8String(byte[] text, int offset, int len) throws IOException { - writeString(new String(text, offset, len, "UTF-8")); + writeString(new String(text, offset, len, StandardCharsets.UTF_8)); } /* @@ -568,12 +569,12 @@ public void writeNull() throws IOException { @Override public void writeNumber(int i) throws IOException { - _avroContext.writeValue(Integer.valueOf(i)); + _avroContext.writeValue(i); } @Override public void writeNumber(long l) throws IOException { - _avroContext.writeValue(Long.valueOf(l)); + _avroContext.writeValue(l); } @Override @@ -588,12 +589,12 @@ public void writeNumber(BigInteger v) throws IOException @Override public void writeNumber(double d) throws IOException { - _avroContext.writeValue(Double.valueOf(d)); + _avroContext.writeValue(d); } @Override public void writeNumber(float f) throws IOException { - _avroContext.writeValue(Float.valueOf(f)); + _avroContext.writeValue(f); } @Override diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroParser.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroParser.java index 5ca7d0a76..c418c0d4d 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroParser.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroParser.java @@ -55,7 +55,7 @@ public static int collectDefaults() return flags; } - private Feature(boolean defaultState) { + Feature(boolean defaultState) { _defaultState = defaultState; _mask = (1 << ordinal()); } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSchema.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSchema.java index e74fc4492..76bf01fe2 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSchema.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroSchema.java @@ -35,7 +35,7 @@ public class AvroSchema implements FormatSchema /** * Lazily instantiated value reader for this schema. */ - protected final AtomicReference _reader = new AtomicReference(); + protected final AtomicReference _reader = new AtomicReference<>(); public AvroSchema(Schema asch) { diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroFieldDefaulters.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroFieldDefaulters.java index 8e401493a..b68ca1bce 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroFieldDefaulters.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroFieldDefaulters.java @@ -42,7 +42,7 @@ public static AvroFieldReader createDefaulter(String name, case START_OBJECT: { Iterator> it = defaultAsNode.fields(); - List readers = new ArrayList(); + List readers = new ArrayList<>(); while (it.hasNext()) { Map.Entry entry = it.next(); String propName = entry.getKey(); @@ -52,7 +52,7 @@ public static AvroFieldReader createDefaulter(String name, } case START_ARRAY: { - List readers = new ArrayList(); + List readers = new ArrayList<>(); for (JsonNode value : defaultAsNode) { readers.add(createDefaulter("", value)); } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java index 81793c406..ac5b4d4f6 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java @@ -320,7 +320,7 @@ protected final void convertNumberToInt() throws IOException protected final void convertNumberToLong() throws IOException { if ((_numTypesValid & NR_INT) != 0) { - _numberLong = (long) _numberInt; + _numberLong = _numberInt; } else if ((_numTypesValid & NR_BIGINT) != 0) { if (BI_MIN_LONG.compareTo(_numberBigInt) > 0 || BI_MAX_LONG.compareTo(_numberBigInt) < 0) { @@ -370,6 +370,7 @@ protected final void convertNumberToBigInteger() throws IOException _numTypesValid |= NR_BIGINT; } + @Override protected final void convertNumberToFloat() throws IOException { // Note: this MUST start with more accurate representations, since we don't know which @@ -398,13 +399,13 @@ protected final void convertNumberToDouble() throws IOException if ((_numTypesValid & NR_BIGDECIMAL) != 0) { _numberDouble = _numberBigDecimal.doubleValue(); } else if ((_numTypesValid & NR_FLOAT) != 0) { - _numberDouble = (double) _numberFloat; + _numberDouble = _numberFloat; } else if ((_numTypesValid & NR_BIGINT) != 0) { _numberDouble = _numberBigInt.doubleValue(); } else if ((_numTypesValid & NR_LONG) != 0) { _numberDouble = (double) _numberLong; } else if ((_numTypesValid & NR_INT) != 0) { - _numberDouble = (double) _numberInt; + _numberDouble = _numberInt; } else { _throwInternal(); } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroReaderFactory.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroReaderFactory.java index 1cefae893..b14f0bbd4 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroReaderFactory.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroReaderFactory.java @@ -27,8 +27,7 @@ public abstract class AvroReaderFactory * To resolve cyclic types, need to keep track of resolved named * types. */ - protected final TreeMap _knownReaders - = new TreeMap(); + protected final TreeMap _knownReaders = new TreeMap<>(); /* /********************************************************************** @@ -306,10 +305,10 @@ protected AvroStructureReader createRecordReader(Schema writerSchema, Schema rea // but first: find fields that only exist in reader-side and need defaults, // and remove those from - Map readerFields = new HashMap(); - List defaultFields = new ArrayList(); + Map readerFields = new HashMap<>(); + List defaultFields = new ArrayList<>(); { - Set writerNames = new HashSet(); + Set writerNames = new HashSet<>(); for (Schema.Field f : writerFields) { writerNames.add(f.name()); } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java index 82a8b394c..15c51549b 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java @@ -368,7 +368,7 @@ public long decodeLong() throws IOException { _inputPtr = ptr; // should be ok to zigzag as int, then sign-extend i = (i >>> 1) ^ (-(i & 1)); - return (long) i; + return i; } private long _decodeLong2(int ptr, long lo) throws IOException @@ -427,7 +427,7 @@ public long _decodeLongSlow() throws IOException { } } i = (i >>> 1) ^ (-(i & 1)); - return (long) i; + return i; } private long _decodeLongSlow2(long lo) throws IOException diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java index 3d740b17e..007e2efc6 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/AvroSchemaHelper.java @@ -65,7 +65,7 @@ public abstract class AvroSchemaHelper * * @since 2.8.7 */ - protected static final Set> STRINGABLE_CLASSES = new HashSet>(Arrays.asList( + protected static final Set> STRINGABLE_CLASSES = new HashSet<>(Arrays.asList( URI.class, URL.class, File.class, BigInteger.class, BigDecimal.class, String.class @@ -121,7 +121,7 @@ protected static String getName(JavaType type) { protected static String getName(Class cls) { String name = cls.getSimpleName(); // Alas, some characters not accepted... - while (name.indexOf("[]") >= 0) { + while (name.contains("[]")) { name = name.replace("[]", "Array"); } return name; @@ -129,7 +129,7 @@ protected static String getName(Class cls) { protected static Schema unionWithNull(Schema otherSchema) { - List schemas = new ArrayList(); + List schemas = new ArrayList<>(); schemas.add(Schema.create(Schema.Type.NULL)); // two cases: existing union @@ -464,8 +464,7 @@ public FullNameKey(String namespace, String name) { } public String nameWithSeparator(char sep) { - final StringBuilder sb = new StringBuilder(1 + _namespace.length() + _name.length()); - return sb.append(_namespace).append(sep).append(_name).toString(); + return _namespace + sep + _name; } @Override diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java index 7dd16589c..696b2e08f 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/DefinedSchemas.java @@ -13,7 +13,7 @@ */ public class DefinedSchemas { - protected final Map _schemas = new LinkedHashMap(); + protected final Map _schemas = new LinkedHashMap<>(); protected SerializerProvider _provider; diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java index 8efffc080..8247eee97 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java @@ -33,7 +33,7 @@ public class RecordVisitor protected Schema _avroSchema; - protected List _fields = new ArrayList(); + protected List _fields = new ArrayList<>(); public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperImpl visitorWrapper) { diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/SchemaBuilder.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/SchemaBuilder.java index 6b3ea744f..cfc92f75b 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/SchemaBuilder.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/SchemaBuilder.java @@ -3,5 +3,5 @@ import org.apache.avro.Schema; public interface SchemaBuilder { - public Schema builtAvroSchema(); + Schema builtAvroSchema(); } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java index 7a5bd4fee..865c9cc90 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/VisitorFormatWrapperImpl.java @@ -159,12 +159,7 @@ public JsonArrayFormatVisitor expectArrayFormat(final JavaType convertedType) { if (convertedType.isArrayType()) { JavaType vt = convertedType.getContentType(); if (vt.hasRawClass(Byte.TYPE)) { - _builder = new SchemaBuilder() { - @Override - public Schema builtAvroSchema() { - return AvroSchemaHelper.typedSchema(Schema.Type.BYTES, convertedType); - } - }; + _builder = () -> AvroSchemaHelper.typedSchema(Schema.Type.BYTES, convertedType); return null; } } @@ -251,9 +246,6 @@ protected T _throwUnsupported(String msg) { } private boolean _isDateTimeType(JavaType type) { - if (Temporal.class.isAssignableFrom(type.getRawClass())) { - return true; - } - return false; + return Temporal.class.isAssignableFrom(type.getRawClass()); } } diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java index 2aa93cb16..15d216183 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/AvroWriteContext.java @@ -214,7 +214,7 @@ protected GenericArray _createArray(Schema schema) } schema = schema.getTypes().get(arraySchemaIndex); } - return new GenericData.Array(8, schema); + return new GenericData.Array<>(8, schema); } // Removed from 2.10, should not be needed any more diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/MapWriteContext.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/MapWriteContext.java index a008e568d..192103c47 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/MapWriteContext.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/MapWriteContext.java @@ -21,7 +21,7 @@ public MapWriteContext(AvroWriteContext parent, AvroGenerator generator, Schema schema, Object currValue) { super(parent, generator, schema, currValue); - _data = new HashMap(); + _data = new HashMap<>(); } @Override diff --git a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java index 3b22e3a66..5a049f9a7 100644 --- a/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java +++ b/avro/src/main/java/com/fasterxml/jackson/dataformat/avro/ser/RootContext.java @@ -136,7 +136,7 @@ protected void _reportError() { private final NonBSGenericDatumWriter _writer() { NonBSGenericDatumWriter w = _writer; if (w == null){ - w = new NonBSGenericDatumWriter(_schema); + w = new NonBSGenericDatumWriter<>(_schema); _writer = w; } return w; diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java index 66843f706..f97c4b724 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/ArrayTest.java @@ -3,6 +3,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.fasterxml.jackson.core.*; @@ -47,7 +48,7 @@ public void testStringArraySequence() throws Exception AvroSchema schema = getStringArraySchema(); List input1 = Arrays.asList("foo", "bar", "...........................................................!"); - List input2 = Arrays.asList("foobar"); + List input2 = Collections.singletonList("foobar"); String[] input3 = new String[] { "a", "Something very much longer than the first entry: and with \u00DCnicod\u00E9 -- at least " +"2 lines full of stuff... 12235u4039680346 -346-0436 34-6 -43609 4363469 436-09", diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java index 5892a4511..c579f3c96 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/AvroTestBase.java @@ -137,7 +137,7 @@ public MediaItem(MediaContent c) { public void addPhoto(Image p) { if (_images == null) { - _images = new ArrayList(); + _images = new ArrayList<>(); } _images.add(p); } @@ -185,7 +185,7 @@ protected MediaContent(MediaContent src) { public void addPerson(String p) { if (_persons == null) { - _persons = new ArrayList(); + _persons = new ArrayList<>(); } _persons.add(p); } @@ -331,7 +331,7 @@ public static void verifyException(Throwable e, String... matches) String lmsg = (msg == null) ? "" : msg.toLowerCase(); for (String match : matches) { String lmatch = match.toLowerCase(); - if (lmsg.indexOf(lmatch) >= 0) { + if (lmsg.contains(lmatch)) { return; } } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java index 0c9ac0181..5dcbecc6d 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BinaryDataTest.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.dataformat.avro; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.JsonParser; @@ -16,8 +16,8 @@ public class BinaryDataTest extends AvroTestBase @JsonPropertyOrder({ "filename", "data", "size" }) static class FilePojo { protected FilePojo() { } - public FilePojo(String text) throws IOException { - data = text.getBytes("UTF-8"); + public FilePojo(String text) { + data = text.getBytes(StandardCharsets.UTF_8); size = data.length; } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java index c88a2ba04..17e890307 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/FileFormatTest.java @@ -38,9 +38,9 @@ private void _testFileFormatOutput(boolean useApacheImpl) throws Exception assertNotNull(bytes); assertEquals(301, bytes.length); - DatumReader datumReader = new GenericDatumReader(schema.getAvroSchema()); + DatumReader datumReader = new GenericDatumReader<>(schema.getAvroSchema()); @SuppressWarnings("resource") - DataFileReader dataFileReader = new DataFileReader(new SeekableByteArrayInput(bytes), + DataFileReader dataFileReader = new DataFileReader<>(new SeekableByteArrayInput(bytes), datumReader); GenericRecord output = dataFileReader.next(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java index 44d043491..76efea690 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/Issue19Test.java @@ -63,12 +63,12 @@ public EventLog(Integer version, Byte eventCount, List events, List sampleEvents = new ArrayList(); + List sampleEvents = new ArrayList<>(); sampleEvents.add(new Event(10, new EventID("sample1", 1, 2))); sampleEvents.add(new Event(20, new EventID("sample2", 10, 20))); sampleEvents.add(new Event(30, new EventID("sample3", 100, 200))); - List sampleProblems = new ArrayList(); + List sampleProblems = new ArrayList<>(); sampleProblems.add(new Problem(800, 801)); sampleProblems.add(new Problem(900, 901)); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java index 8922351c6..0255a1a4b 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapTest.java @@ -31,7 +31,7 @@ public class MapTest extends AvroTestBase +"]}" ; static class Container { - public Map stuff = new LinkedHashMap(); + public Map stuff = new LinkedHashMap<>(); public void setStuff(Map arg) { stuff = arg; @@ -197,7 +197,7 @@ public void testRootMapSequence() throws Exception } private Map _map(String... stuff) { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); for (int i = 0, end = stuff.length; i < end; i += 2) { map.put(stuff[i], stuff[i+1]); } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java index fe8a9fa19..b9f3e041a 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapWithUnionTest.java @@ -99,9 +99,9 @@ public void testRootMapWithUnionSequence() throws Exception public void testMapContainerWithNested() throws IOException { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); map.put("hello", "world"); - Map otherMap = new LinkedHashMap(); + Map otherMap = new LinkedHashMap<>(); otherMap.put("foo", "bar"); otherMap.put("zap", "bing"); map.put("otherMap", otherMap); @@ -125,7 +125,7 @@ public void testMapContainerWithNested() throws IOException } private Map _map(Object... args) { - Map m = new LinkedHashMap(); + Map m = new LinkedHashMap<>(); for (int i = 0; i < args.length; i += 2) { m.put((String) args[i], args[i+1]); } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java index 25c1c67fb..b70937b8f 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/MapperConfigTest.java @@ -10,12 +10,7 @@ public class MapperConfigTest extends AvroTestBase { private final AvroFactory AVRO_F = new AvroFactory(); - private final FormatSchema BOGUS_SCHEMA = new FormatSchema() { - @Override - public String getSchemaType() { - return "Test"; - } - }; + private final FormatSchema BOGUS_SCHEMA = () -> "Test"; /* /********************************************************** diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java index 7c2424b1f..808c8d620 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RootSequenceTest.java @@ -24,9 +24,9 @@ public void testReadWriteIntSequence() throws Exception // First: write a sequence of 3 root-level ints SequenceWriter sw = MAPPER.writer(schema).writeValues(b); - sw.write(Integer.valueOf(1)); - sw.write(Integer.valueOf(123456)); - sw.write(Integer.valueOf(-999)); + sw.write(1); + sw.write(123456); + sw.write(-999); sw.close(); byte[] bytes = b.toByteArray(); diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java index 032f703ad..b9b859e13 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/UUIDTest.java @@ -1,5 +1,6 @@ package com.fasterxml.jackson.dataformat.avro; +import java.nio.charset.StandardCharsets; import java.util.UUID; // @since 2.10 @@ -20,7 +21,7 @@ protected UUIDWrapper() { } public void testUUIDRoundtrip() throws Exception { final AvroSchema schema = MAPPER.schemaFor(UUIDWrapper.class); - UUIDWrapper input = new UUIDWrapper(UUID.nameUUIDFromBytes("BOGUS".getBytes("UTF-8"))); + UUIDWrapper input = new UUIDWrapper(UUID.nameUUIDFromBytes("BOGUS".getBytes(StandardCharsets.UTF_8))); byte[] avro = MAPPER.writer(schema).writeValueAsBytes(input); UUIDWrapper output = MAPPER.readerFor(UUIDWrapper.class) diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroAliasTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroAliasTest.java index 72a1ae329..58c4f68af 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroAliasTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroAliasTest.java @@ -41,19 +41,19 @@ public static class AliasedNameEmployee { } @AvroAlias(alias = "Size", space = "com.fasterxml.jackson.dataformat.avro.AvroTestBase$") - public static enum NewSize { + public enum NewSize { SMALL, LARGE; } @AvroAlias(alias = "NewestSize") - public static enum NewerSize { + public enum NewerSize { SMALL, LARGE; } @AvroAlias(alias = "NewerSize") - public static enum NewestSize { + public enum NewestSize { SMALL, LARGE; } diff --git a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroEncodeTest.java b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroEncodeTest.java index b229e5197..55bd6313a 100644 --- a/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroEncodeTest.java +++ b/avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroEncodeTest.java @@ -151,7 +151,7 @@ public void setup() throws IOException { Map> mv = new HashMap<>(); wrapper.component.mapValue = mv; mv.put("birds", new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6))); - mv.put("cats", new ArrayList()); + mv.put("cats", new ArrayList<>()); mv.put("dogs", new ArrayList<>(Arrays.asList(-1234, 56, 6767, 54134, 57, 86))); wrapper.component.stringValue = "Hello World!"; wrapper.component.uuidValue = UUID.randomUUID();