if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
}
context.put(this, fields);
}
InputChunked inputChunked = new InputChunked(input, 1024);
for (int i = 0, n = fields.length; i < n; i++) {
CachedField cachedField = fields[i];
try {
if (cachedField == null) {
if (TRACE) trace("kryo", "Skip obsolete field.");
inputChunked.nextChunks();
continue;
}
if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");
Object value;
Class concreteType = cachedField.valueClass;
Serializer serializer = cachedField.serializer;
if (concreteType == null) {
Registration registration = kryo.readClass(inputChunked);
if (registration == null)
value = null;
else {
if (serializer == null) serializer = registration.getSerializer();
if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
value = kryo.readObject(inputChunked, registration.getType(), serializer);
}
} else {
if (serializer == null) cachedField.serializer = serializer = kryo.getSerializer(concreteType);
if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
if (cachedField.canBeNull)
value = kryo.readObjectOrNull(inputChunked, concreteType, serializer);
else
value = kryo.readObject(inputChunked, concreteType, serializer);
}
cachedField.set(object, value);
inputChunked.nextChunks();
} catch (IllegalAccessException ex) {
throw new KryoException("Error accessing field: " + cachedField + " (" + getType().getName() + ")", ex);
} catch (KryoException ex) {
ex.addTrace(cachedField + " (" + getType().getName() + ")");
throw ex;