XWikiDocument toXML lists attachments in an inconsistent order

If it's your first Google Code-In task it's highly recommended to start with Become a community member.


  • The student will need to have a Jira account, if it's not the case you can signup here
  • The student will also need a https://www.github.com account. You might also want to take a look at Git and GitHub interface documentations.

  • Assign yourself to the Jira issue


Since toXML lists attachment in the order in the internal List, and that the internal list reads them in the order the database gives them, which gives them (database specific) in the order of creation in the DB, the XML output of XWiki can be inconsistent accross wikis especially when importing XMLs.

This leads to differences when comparing the XML although they are the same (problem verified with the SVN commit app).

We need to make sure that the attachments are always listed in the same order (ideally the creation date).

Since getting the creation order is complex we should probably just use ASCII order (any order is good as long as it's stable).

The best is probably the refactor XWikiDocument#attachmentList into a TreeMap (as a bonus it will improve the speed of methods like XWikiDocument#getAttachment()).

Expected Outcome

  • The student must commit the changes and create a pull request on https://github.com/xwiki/xwiki-platform The summary of the Pull Request must have a first line matching the JIRA issue following by a colon and then the title of this issue Add a comment in the jira issue mentioning your pull request and provide a link to it


Getting help

If you have any question you should use the Chat (faster answer, but when there is someone around) or the Forum (more people available, but slower answer).

Task tags

  • java

Students who completed this task

Akshit Dewan

Task type

  • code Code