@Override
public void setSchema(Schema actual) {
// if expected is unset and actual is a specific record,
// then default expected to schema of currently loaded class
if (schema == null && actual != null && actual.getType() == Schema.Type.RECORD) {
SpecificData data = getSpecificData();
Class c = data.getClass(actual);
if (c != null && SpecificRecord.class.isAssignableFrom(c)) {
schema = data.getSchema(c);
}
}
if (schema == null) {
schema = actual;
}