Skip to content

Commit

Permalink
Fix reflection bug that broke tests during coverage. (#519)
Browse files Browse the repository at this point in the history
Coverage analysis injects tracking fields, which can show up in
`getDeclaredFields()`; this removes the field `__$hits$__` when present.
  • Loading branch information
crutcher committed Jan 17, 2024
1 parent 45f49e9 commit f06c113
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ private static String jsonStructure(Class<?> structured) {
StringBuilder jsonSchema = new StringBuilder();
jsonSchema.append("{\n");
for (Field field : structured.getDeclaredFields()) {
jsonSchema.append(format("\"%s\": (%s),\n", field.getName(), descriptionFor(field)));
String name = field.getName();
if (name.equals("__$hits$__")) {
// Skip coverage instrumentation field.
continue;
}
jsonSchema.append(format("\"%s\": (%s),\n", name, descriptionFor(field)));
}
jsonSchema.append("}");
return jsonSchema.toString();
Expand Down

0 comments on commit f06c113

Please sign in to comment.