This issue has been created
There are 2 updates.
 
 
AntiSpam Application / cid:jira-generated-image-avatar-3dbdbd98-9a6a-45a8-8d70-a60cf2694ad1 ANTISPAM-86 Open

The Authors list is displayed in a random order

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-53df4257-05ae-4a16-8f18-913932f75eb8 Vincent Massol created this issue on 18/Aug/26 18:10
 
Summary: The Authors list is displayed in a random order
Issue Type: cid:jira-generated-image-avatar-3dbdbd98-9a6a-45a8-8d70-a60cf2694ad1 Bug
Affects Versions: 1.8
Assignee: Unassigned
Components: UI
Created: 18/Aug/26 18:10
Priority: cid:jira-generated-image-static-major-cf387830-9200-4264-b677-d66c03bfdb9c Major
Reporter: Vincent Massol
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.

 
 

2 updates

 
cid:jira-generated-image-avatar-53df4257-05ae-4a16-8f18-913932f75eb8 Changes by Vincent Massol on 18/Aug/26 18:10
 
Fix Version: 1.13
Description: h2. Problem

On the AntiSpam home page \ ("Delete Spam User and Pages" \ ), after searching for a spam term, the _Authors_ *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.

h2. 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.

h2. 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:

{
code noformat }
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>
{
code noformat }

h2. 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.