Skip to content

Commit

Permalink
Merge branch '2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 3, 2023
2 parents 86a728d + bef6905 commit 5e2350e
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public static int collectDefaults()
}
return flags;
}
private Feature(boolean defaultState) {

Feature(boolean defaultState) {
_defaultState = defaultState;
_mask = (1 << ordinal());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AvroSchema implements FormatSchema
/**
* Lazily instantiated value reader for this schema.
*/
protected final AtomicReference<AvroStructureReader> _reader = new AtomicReference<AvroStructureReader>();
protected final AtomicReference<AvroStructureReader> _reader = new AtomicReference<>();

public AvroSchema(Schema asch)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static AvroFieldReader createDefaulter(String name,
case START_OBJECT:
{
Iterator<Map.Entry<String,JsonNode>> it = defaultAsNode.fields();
List<AvroFieldReader> readers = new ArrayList<AvroFieldReader>();
List<AvroFieldReader> readers = new ArrayList<>();
while (it.hasNext()) {
Map.Entry<String,JsonNode> entry = it.next();
String propName = entry.getKey();
Expand All @@ -52,7 +52,7 @@ public static AvroFieldReader createDefaulter(String name,
}
case START_ARRAY:
{
List<AvroFieldReader> readers = new ArrayList<AvroFieldReader>();
List<AvroFieldReader> readers = new ArrayList<>();
for (JsonNode value : defaultAsNode) {
readers.add(createDefaulter("", value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected final void convertNumberToInt() throws JacksonException
protected final void convertNumberToLong() throws JacksonException
{
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) {
Expand Down Expand Up @@ -443,13 +443,13 @@ protected final void convertNumberToDouble() throws JacksonException
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public abstract class AvroReaderFactory
* To resolve cyclic types, need to keep track of resolved named
* types.
*/
protected final TreeMap<String, AvroStructureReader> _knownReaders
= new TreeMap<String, AvroStructureReader>();
protected final TreeMap<String, AvroStructureReader> _knownReaders = new TreeMap<>();

/*
/**********************************************************************
Expand Down Expand Up @@ -303,10 +302,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<String,Schema.Field> readerFields = new HashMap<String,Schema.Field>();
List<Schema.Field> defaultFields = new ArrayList<Schema.Field>();
Map<String,Schema.Field> readerFields = new HashMap<>();
List<Schema.Field> defaultFields = new ArrayList<>();
{
Set<String> writerNames = new HashSet<String>();
Set<String> writerNames = new HashSet<>();
for (Schema.Field f : writerFields) {
writerNames.add(f.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,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
Expand Down Expand Up @@ -436,7 +436,7 @@ public long _decodeLongSlow() throws IOException {
}
}
i = (i >>> 1) ^ (-(i & 1));
return (long) i;
return i;
}

private long _decodeLongSlow2(long lo) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class AvroSchemaHelper
/**
* Default stringable classes
*/
protected static final Set<Class<?>> STRINGABLE_CLASSES = new HashSet<Class<?>>(Arrays.asList(
protected static final Set<Class<?>> STRINGABLE_CLASSES = new HashSet<>(Arrays.asList(
URI.class, URL.class, File.class,
BigInteger.class, BigDecimal.class,
String.class
Expand Down Expand Up @@ -118,7 +118,7 @@ protected static String getTypeName(JavaType type) {

protected static Schema unionWithNull(Schema otherSchema)
{
List<Schema> schemas = new ArrayList<Schema>();
List<Schema> schemas = new ArrayList<>();
schemas.add(Schema.create(Schema.Type.NULL));

// two cases: existing union
Expand Down Expand Up @@ -437,8 +437,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public class DefinedSchemas
{
protected final Map<JavaType, Schema> _schemas = new LinkedHashMap<JavaType, Schema>();
protected final Map<JavaType, Schema> _schemas = new LinkedHashMap<>();

protected SerializerProvider _provider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class RecordVisitor

protected Schema _avroSchema;

protected List<Schema.Field> _fields = new ArrayList<Schema.Field>();
protected List<Schema.Field> _fields = new ArrayList<>();

public RecordVisitor(SerializerProvider p, JavaType type, VisitorFormatWrapperImpl visitorWrapper)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import org.apache.avro.Schema;

public interface SchemaBuilder {
public Schema builtAvroSchema();
Schema builtAvroSchema();
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,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;
}
}
Expand Down Expand Up @@ -243,9 +238,6 @@ protected <T> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected GenericArray<Object> _createArray(Schema schema)
}
schema = schema.getTypes().get(arraySchemaIndex);
}
return new GenericData.Array<Object>(8, schema);
return new GenericData.Array<>(8, schema);
}

// Removed from 2.10, should not be needed any more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MapWriteContext(AvroWriteContext parent, AvroGenerator generator,
Schema schema, Object currValue)
{
super(parent, generator, schema, currValue);
_data = new HashMap<String,Object>();
_data = new HashMap<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected void _reportError() {
private final NonBSGenericDatumWriter<Object> _writer() {
NonBSGenericDatumWriter<Object> w = _writer;
if (w == null){
w = new NonBSGenericDatumWriter<Object>(_schema);
w = new NonBSGenericDatumWriter<>(_schema);
_writer = w;
}
return w;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 tools.jackson.core.*;
Expand Down Expand Up @@ -48,7 +49,7 @@ public void testStringArraySequence() throws Exception
AvroSchema schema = getStringArraySchema();
List<String> input1 = Arrays.asList("foo", "bar",
"...........................................................!");
List<String> input2 = Arrays.asList("foobar");
List<String> 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public MediaItem(MediaContent c) {

public void addPhoto(Image p) {
if (_images == null) {
_images = new ArrayList<Image>();
_images = new ArrayList<>();
}
_images.add(p);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ protected MediaContent(MediaContent src) {

public void addPerson(String p) {
if (_persons == null) {
_persons = new ArrayList<String>();
_persons = new ArrayList<>();
}
_persons.add(p);
}
Expand Down Expand Up @@ -337,7 +337,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;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tools.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;

Expand All @@ -17,8 +17,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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ private void _testFileFormatOutput(AvroFactory af) throws Exception
assertNotNull(bytes);
assertEquals(301, bytes.length);

DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>(schema.getAvroSchema());
DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(schema.getAvroSchema());
@SuppressWarnings("resource")
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<GenericRecord>(new SeekableByteArrayInput(bytes),
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(new SeekableByteArrayInput(bytes),
datumReader);
GenericRecord output = dataFileReader.next();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public EventLog(Integer version, Byte eventCount, List<Event> events, List<Probl

public void testIssue19() throws Exception
{
List<Event> sampleEvents = new ArrayList<Event>();
List<Event> 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<Problem> sampleProblems = new ArrayList<Problem>();
List<Problem> sampleProblems = new ArrayList<>();
sampleProblems.add(new Problem(800, 801));
sampleProblems.add(new Problem(900, 901));

Expand Down
4 changes: 2 additions & 2 deletions avro/src/test/java/tools/jackson/dataformat/avro/MapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MapTest extends AvroTestBase
+"]}"
;
static class Container {
public Map<String,String> stuff = new LinkedHashMap<String,String>();
public Map<String,String> stuff = new LinkedHashMap<>();

public void setStuff(Map<String,String> arg) {
stuff = arg;
Expand Down Expand Up @@ -194,7 +194,7 @@ public void testRootMapSequence() throws Exception
}

private Map<String,String> _map(String... stuff) {
Map<String,String> map = new LinkedHashMap<String,String>();
Map<String,String> map = new LinkedHashMap<>();
for (int i = 0, end = stuff.length; i < end; i += 2) {
map.put(stuff[i], stuff[i+1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public void testRootMapWithUnionSequence() throws Exception

public void testMapContainerWithNested() throws IOException
{
Map<String,Object> map = new LinkedHashMap<String,Object>();
Map<String,Object> map = new LinkedHashMap<>();
map.put("hello", "world");
Map<String,String> otherMap = new LinkedHashMap<String,String>();
Map<String,String> otherMap = new LinkedHashMap<>();
otherMap.put("foo", "bar");
otherMap.put("zap", "bing");
map.put("otherMap", otherMap);
Expand All @@ -125,7 +125,7 @@ public void testMapContainerWithNested() throws IOException
}

private Map<String,Object> _map(Object... args) {
Map<String,Object> m = new LinkedHashMap<String,Object>();
Map<String,Object> m = new LinkedHashMap<>();
for (int i = 0; i < args.length; i += 2) {
m.put((String) args[i], args[i+1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tools.jackson.dataformat.avro;

import java.nio.charset.StandardCharsets;
import java.util.UUID;

// @since 2.10
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public static class AliasedNameEmployee {
}

@AvroAlias(alias = "Size", space = "tools.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;
}
Expand Down
Loading

0 comments on commit 5e2350e

Please sign in to comment.