Skip to content
Snippets Groups Projects
Commit 74d91015 authored by Simon Urli's avatar Simon Urli
Browse files

XWIKI-21616: Potential NPE when having ToggleableFilterPreferenceClass xobjects with holes

  * Protect against NPE and cover it in unit test
parent 73a7fc7b
No related branches found
No related tags found
No related merge requests found
......@@ -134,7 +134,9 @@ private void copyToggleableFilterPreferences(XWikiDocument userDocument) throws
List<BaseObject> xObjects = notificationConfiguration.getXObjects(TOGGLEABLE_FILTER_PREFERENCE_CLASS);
for (BaseObject xObject : xObjects) {
userDocument.addXObject(xObject.duplicate());
if (xObject != null) {
userDocument.addXObject(xObject.duplicate());
}
}
}
} finally {
......
......@@ -129,7 +129,7 @@ void onEvent() throws NotificationException, XWikiException
when(obj1.duplicate()).thenReturn(obj1bis);
when(obj2.duplicate()).thenReturn(obj2bis);
when(wikiNotificationConfiguration.getXObjects(UserAddedEventListener.TOGGLEABLE_FILTER_PREFERENCE_CLASS))
.thenReturn(Arrays.asList(obj1, obj2));
.thenReturn(Arrays.asList(obj1, null, obj2, null));
this.userAddedEventListener.onEvent(null, userDoc, null);
verify(this.notificationFilterPreferenceManager).saveFilterPreferences(documentReference, expectedSet);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment