Skip to content

Commit

Permalink
Fixed #213. Now CompatibleFieldSerializer should work properly with c…
Browse files Browse the repository at this point in the history
…lasses having generic type parameters.
  • Loading branch information
romix committed May 1, 2014
1 parent 8d7d0b5 commit 1e9b23f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ public T read (Kryo kryo, Input input, Class<T> type) {
}

InputChunked inputChunked = new InputChunked(input, 1024);
boolean hasGenerics = getGenerics() != null;
for (int i = 0, n = fields.length; i < n; i++) {
CachedField cachedField = fields[i];
if(cachedField != null && hasGenerics) {
// Generic type used to instantiate this field could have
// been changed in the meantime. Therefore take the most
// up-to-date definition of a field
cachedField = getField(cachedField.field.getName());
}
if (cachedField == null) {
if (TRACE) trace("kryo", "Skip obsolete field.");
inputChunked.nextChunks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ public void setGenerics (Kryo kryo, Class[] generics) {
rebuildCachedFields(true);
}
}

/** Get generic type parameters of the class controlled by this serializer.
* @return generic type parameters or null, if there are none.
*/
public Class[] getGenerics() {
return generics;
}

protected void initializeCachedFields () {
}
Expand Down

0 comments on commit 1e9b23f

Please sign in to comment.