In a DocumentCreated EventListener, if the saved document is modified and saved again, a DocumentCreatedEvent is sent instead of a DocumentUpdatedEvent
I wonder if this is actually (still) a bug. When you save a "new" document that is not actually new, this code will replace the original document by the existing document and then this code will delete the previous version of the document. Therefore, it is correct that you get a DocumentCreatedEvent as you just deleted and recreated the document. As Thomas Mortagne mentions, the real problem here is that you're modifying a shared XWikiDocument instance which is something you should never do.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.