mirror of
https://github.com/apache/nifi.git
synced 2025-02-28 22:49:10 +00:00
NIFI-10890 Replaced HashMap with LinkedHashMap in JsonRowRecordReader
- Updated unit test based on deterministic behavior of LinkedHashMap This closes #6726 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
3a7ec5d542
commit
ab8e9aa8df
@ -43,8 +43,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiPredicate;
|
||||
@ -119,7 +119,7 @@ public abstract class AbstractJsonRowRecordReader implements RecordReader {
|
||||
|
||||
this.strategy = strategy;
|
||||
this.captureFieldPredicate = captureFieldPredicate;
|
||||
capturedFields = new HashMap<>();
|
||||
capturedFields = new LinkedHashMap<>();
|
||||
|
||||
try {
|
||||
jsonParser = jsonFactory.createParser(in);
|
||||
@ -306,7 +306,7 @@ public abstract class AbstractJsonRowRecordReader implements RecordReader {
|
||||
final MapDataType mapDataType = (MapDataType) dataType;
|
||||
final DataType valueType = mapDataType.getValueType();
|
||||
|
||||
final Map<String, Object> mapValue = new HashMap<>();
|
||||
final Map<String, Object> mapValue = new LinkedHashMap<>();
|
||||
|
||||
final Iterator<Map.Entry<String, JsonNode>> fieldItr = fieldNode.fields();
|
||||
while (fieldItr.hasNext()) {
|
||||
@ -372,7 +372,7 @@ public abstract class AbstractJsonRowRecordReader implements RecordReader {
|
||||
|
||||
private Record createRecordFromRawValue(final JsonNode fieldNode, final RecordSchema childSchema) throws IOException {
|
||||
final Iterator<String> fieldNames = fieldNode.fieldNames();
|
||||
final Map<String, Object> childValues = new HashMap<>();
|
||||
final Map<String, Object> childValues = new LinkedHashMap<>();
|
||||
while (fieldNames.hasNext()) {
|
||||
final String childFieldName = fieldNames.next();
|
||||
|
||||
|
@ -423,7 +423,7 @@ class TestJsonTreeRowRecordReader {
|
||||
fields.add(new RecordField("id", RecordFieldType.INT.getDataType()));
|
||||
final RecordSchema schema = new SimpleRecordSchema(fields);
|
||||
|
||||
final String expectedMap = "{id=1, name=John Doe, address=123 My Street, city=My City, state=MS, zipCode=11111, country=USA, account=MapRecord[{balance=4750.89, id=42}]}";
|
||||
final String expectedMap = "{id=1, name=John Doe, address=123 My Street, city=My City, state=MS, zipCode=11111, country=USA, account=MapRecord[{id=42, balance=4750.89}]}";
|
||||
final String expectedRecord = String.format("MapRecord[%s]", expectedMap);
|
||||
try (final InputStream in = new FileInputStream("src/test/resources/json/single-element-nested.json");
|
||||
final JsonTreeRowRecordReader reader = new JsonTreeRowRecordReader(in, mock(ComponentLog.class), schema, dateFormat, timeFormat, timestampFormat)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user