Uploaded image for project: 'AntiSpam Application'
  1. AntiSpam Application
  2. ANTISPAM-86

The Authors list is displayed in a random order

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.13
    • 1.8
    • UI
    • None
    • Unknown
    • N/A
    • N/A

    Description

      Problem

      On the AntiSpam home page ("Delete Spam User and Pages"), after searching for a spam term, the Authors section lists the authors of the matching pages in an arbitrary order which can change from one XWiki restart to the next, even for the very same set of authors.

      Cause

      AntiSpamScriptService.getLastAuthorReferences() collects the authors into a HashSet<DocumentReference> and AntiSpam.WebHome iterates that set directly, so the displayed order is the set's iteration order.

      That order is not stable across JVM runs: EntityReference.hashCode() includes getType(), and EntityType is an enum whose hashCode() is the identity hash code, which differs from one JVM run to the next. As a result the bucket order of the references — and hence the display order — is effectively arbitrary per run.

      Consequence

      Beyond the unstable UI, this makes the AntiSpamIT.verifyHomePageFeatures functional test flicker, since it asserts the exact text of the Authors list. It passed for a long time (identity hash codes happen to be reproducible for a given allocation sequence) and then started failing on an unrelated change which only shifted that sequence:

      expected: <xwiki:XWiki.spamuser
                 xwiki:XWiki.superadmin Excluded for safety since the user has protected access to the page>
      but was:  <xwiki:XWiki.superadmin Excluded for safety since the user has protected access to the page
                 xwiki:XWiki.spamuser>
      

      Proposal

      Return a sorted set from getLastAuthorReferences() so that the Authors list has a stable, alphabetical order. EntityReference implements Comparable, so a TreeSet is enough.

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: