Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25614

Concurrent refreshes of the WYSIWYG editor content can fail with a ConcurrentModificationException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • 18.10.0-rc-1
    • 16.10.0
    • WYSIWYG Editor
    • None
    • Unknown

    Description

      Analysis, text and proposed fix by Claude Code with Opus 5.5

      Steps to reproduce

      1. Three users edit the same page in realtime with the WYSIWYG editor.
      2. One of them inserts a macro.

      The other users refresh their edited content at the same time, in order to render the inserted macro (each editor asks the server to convert its content).

      Expected: the content is refreshed for all users.
      Actual: sometimes the refresh fails for one of the users (the inserted macro isn't rendered in their editor), and the server logs:

      java.util.ConcurrentModificationException
      	at java.base/java.util.ArrayList.sort(ArrayList.java:1806)
      	at org.xwiki.wysiwyg.internal.cleaner.DefaultHTMLCleaner.clean(DefaultHTMLCleaner.java:63)
      	at org.xwiki.wysiwyg.internal.converter.DefaultHTMLConverter.parseAndRender(DefaultHTMLConverter.java:210)
      	at org.xwiki.wysiwyg.script.WysiwygEditorScriptService.parseAndRender(WysiwygEditorScriptService.java:254)
      

      This was observed while running RealtimeWYSIWYGEditorIT on Chrome. Any concurrent conversions of the WYSIWYG editor content can be affected, not only in realtime sessions, but realtime editing makes them likely because every user refreshes their content as soon as someone inserts a macro.

      Analysis

      DefaultHTMLCleaner is a singleton, and clean() sorts the injected list of WYSIWYG specific HTML filters in place, on each call. Concurrent calls sort the same list at the same time, which throws a ConcurrentModificationException.

      Proposed fix

      Sort a copy of the list of filters.

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              MichaelHamann Michael Hamann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: