Details
Description
It is possible to get a ConcurrentModificationException in Right when a right is added (or removed) while some other code like the Solr indexer accesses rights, e.g., to convert a right from a string. This can be seen in the following log output that happened during the execution of
Validating HTML5 validity for [http://127.0.0.1:8080/xwiki/bin/view/Dashboard/UserDashboardPreferencesClass] executed with credentials Admin:admin
in org.xwiki.test.webstandards.framework.DefaultValidationTest:
2023-05-23 17:39:48,514 [Exec Stream Pumper] - 2023-05-23 17:39:48,513 [XWiki Solr index thread] ERROR c.x.x.d.XWikiDocument - Failed to render title for [xwiki:AppWithinMinutes.LiveTableTemplate] 2023-05-23 17:39:48,515 [Exec Stream Pumper] - java.util.ConcurrentModificationException: null 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.security.authorization.Right.toRight(Right.java:358) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.security.authorization.internal.XWikiCachingRightService.hasAccessLevel(XWikiCachingRightService.java:308) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at com.xpn.xwiki.doc.DefaultDocumentAccessBridge.hasRight(DefaultDocumentAccessBridge.java:996) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at com.xpn.xwiki.doc.DefaultDocumentAccessBridge.hasRight(DefaultDocumentAccessBridge.java:981) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at com.xpn.xwiki.doc.DefaultDocumentAccessBridge.isDocumentViewable(DefaultDocumentAccessBridge.java:823) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.sheet.internal.SheetDocumentDisplayer.maybeDisplayWithSheet(SheetDocumentDisplayer.java:178) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:111) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:52) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:68) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:42) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at com.xpn.xwiki.doc.XWikiDocument.getRenderedTitle(XWikiDocument.java:1926) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.search.solr.internal.metadata.DocumentSolrMetadataExtractor.setFieldsInternal(DocumentSolrMetadataExtractor.java:117) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.search.solr.internal.metadata.AbstractSolrMetadataExtractor.getSolrDocument(AbstractSolrMetadataExtractor.java:166) 2023-05-23 17:39:48,515 [Exec Stream Pumper] - at org.xwiki.search.solr.internal.DefaultSolrIndexer.getSolrDocument(DefaultSolrIndexer.java:510) 2023-05-23 17:39:48,516 [Exec Stream Pumper] - at org.xwiki.search.solr.internal.DefaultSolrIndexer.processBatch(DefaultSolrIndexer.java:419) 2023-05-23 17:39:48,516 [Exec Stream Pumper] - at org.xwiki.search.solr.internal.DefaultSolrIndexer.run(DefaultSolrIndexer.java:384) 2023-05-23 17:39:48,516 [Exec Stream Pumper] - at java.base/java.lang.Thread.run(Thread.java:834)
Note that this error is not (easily) reproducible and most likely happens very rarely, it is a rare race condition. The code with the race condition has been introduced in 4.0 Milestone 2 as part of https://github.com/xwiki/xwiki-platform/commit/3dc7be31.