Skip to content

Commit

Permalink
address the comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
horizonzy committed Nov 13, 2023
1 parent 1e767a3 commit 685d9e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,9 @@ public static Schema makeNullable(Schema schema) {
private static final ConcurrentMap<Class<?>, Field[]> NATIVE_FIELDS_CACHE = new ConcurrentHashMap<>();

// Return of this class and its superclasses to serialize.
private static Field[] getCachedFields(Class<?> recordClass, boolean orderBy) {
return MapUtil.computeIfAbsent(orderBy ? FIELDS_CACHE : NATIVE_FIELDS_CACHE, recordClass,
rc -> getFields(rc, true, orderBy));
private static Field[] getCachedFields(Class<?> recordClass, boolean useDeterministicFieldOrder) {
return MapUtil.computeIfAbsent(useDeterministicFieldOrder ? FIELDS_CACHE : NATIVE_FIELDS_CACHE, recordClass,
rc -> getFields(rc, true, useDeterministicFieldOrder));
}

private static Field[] getFields(Class<?> recordClass, boolean excludeJava, boolean orderBy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ void fieldsOrder() {
schema = new ReflectData(false).getSchema(Meta.class);
fields = schema.getFields();
assertEquals(fields.size(), 4);
assertEquals(fields.get(0).name(), "f1");
assertEquals(fields.get(1).name(), "f4");
assertEquals(fields.get(2).name(), "f2");
assertEquals(fields.get(3).name(), "f3");

Field[] declaredFields = Meta.class.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) {
assertEquals(fields.get(i).name(), declaredFields[i].getName());
}
}

private interface CrudProtocol<R, I> extends OtherProtocol<I> {
Expand Down

0 comments on commit 685d9e7

Please sign in to comment.