Renaming Macros using JAVA in a plugin

Hi,
Has anyone been able to successfully rename their xhtml-macro macro key?

I have a plugin that has a macro called dropdown-list. This is an old plugin, been on the market place for a few years. Recently I have found that a the macro key clashes with another plugins macro and I need to rename my key to remove the clash and allow both plugins to operate on the same site.

I had a go at this renaming, using a thread after the plugin has been upgraded (started). The process was:

  1. Find all the pages with my old macro (using search v2).
  2. For each page:
    Scan the page body, find my macro and rename it (using Document (XML) parser etc…)
    Use the pagemanager.saveNewVersion() to persist the change.

This worked well in 3 test environments, but since placing this on the marketpace, I am finding that the implementation is having random failures, that I don’t know the cause of.

There are 2 main failures, here are the ERRORS in log file:

  1. Unable to resolve owner of loading collection [[com.atlassian.confluence.core.ContentEntityObject.contentProperties#186484550]] for second level caching
  2. javax.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [com.atlassian.confluence.pages.Page#266934980]

So, has anyone successfully bulk renamed macros, if so how did you do it?

If not, Atlassian can you please assist, this has broken a few customers with thousands of pages using this macro?

We are also working on the same issue and found suggestion from Atlassian as following PR. But , somehow we are yet to manage it to work.