Have I found a bug in Confluence?


In an existing, working module I have this code:
List attachments = page.getAttachments();

getAttachments() is deprecated so I need to use getAllVersionsOfAttachments() instead.
Both getAttachments() and getAllVersionsOfAttachments() are methods within the Interface AttachmentManager:
When I change the code from:
List attachments = page.getAttachments();
List attachments = page.getAllVersionsOfAttachments(); the error “The method getAllVersionsOfAttachments() is undefined for the type Page” shows up.

If I manually type in: List attachments = page. the list of options comes up but getAllVersionsOfAttachments() isn’t on that list.
How can this be an error when they are both methods within the same interface and the interface has already been in use by getAttachments()?
Why would getAllVersionsOfAttachments() not be on the list of code that I can insert? Have I found a bug in Confluence?

Baffled! Any help is much appreciated.


Hi Jimmy,

Thanks for raising this question and I would try to help by giving some information on its usage:

  • getAttachments() method exists in ContentEntityObject type. Since com.atlassian.confluence.pages.Page is a type of ConfluenceEntityObject, you are able to use this method in Page type too.
  • I don’t see getAttachments() method marked as deprecated in Page, however what I see is that AttachmentManager.getAttachments(id) is marked as deprecated since 7.5.
  • getAllVersionsOfAttachments(contentEntityObject) is a method in AttachmentManager type not Page type. If you want to use this method, you will need to use AttachmentManager’s API to rely on this method. However for plugin development and long-term compatibility, I would recommend you to use AttachmentService instead for finding attachments and rely on Expansions.

Please let me know if you have any further questions.


1 Like

Thank you very much.
I will try this.


I looked Page class up:

In Method Summary it says:
List<Attachment> getAttachments()
Don’t use it directly, use AttachmentManager.getAttachments(page) instead.