Skip to content

Commit

Permalink
Fix nullability not being allowed for collections in PersistenceLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed May 13, 2023
1 parent 91b5964 commit f8004ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -166,6 +166,9 @@ private static void deserialise(PersistField field, Object instance, Object oldV
// TODO: this is pretty ugly.
if (!Collection.class.isAssignableFrom(collectionType) && !Map.class.isAssignableFrom(collectionType))
throw loadException;
if (Collection.class.isAssignableFrom(type) && !root.keyExists(field.key))
return;

if (List.class.isAssignableFrom(type)) {
List<Object> list = (List<Object>) (!List.class.isAssignableFrom(collectionType) ? Lists.newArrayList()
: collectionType.newInstance());
Expand Down
Expand Up @@ -65,6 +65,12 @@ public void loadsCollections() {
}
}

@Test
public void loadsNullSets() {
SpecificCollectionClassTest test = PersistenceLoader.load(SpecificCollectionClassTest.class, root);
assertEquals(test.list, null);
}

@Test
public void longLoadSaveTest() {
LongLoadSaveTest load = new LongLoadSaveTest();
Expand Down

0 comments on commit f8004ec

Please sign in to comment.