maeste/jboss-as — comment on commit 8ec9b19d5386abe27c577840fd095c26b4d41cbf
File: controller/src/main/java/org/jboss/as/controller/OperationContextImpl.java line 183
By bstansberry:

This returns a clone, but whatever the caller does with that clone won't be reflected in the ManagementResourceRegistration held in the ModelController. So it won't change anything.

The way it works for the Resources is readResourceForUpdate clones the Resource tree the first time it is invoked. Then doCompleteStep publishes that clone back to the ModelControllerImpl if the operation is a success.

But, the cloning strategy may have been a bad idea on my part for this use case. It works in readResourceForUpdate because no one except ModelControllerImpl holds a ref to the Resource tree beyond the scope of an operation. So if a later op clones the Resource tree and publishes it back to the ModelControllerImpl, no one else is left holding a stale reference. But here we're handing out a ref to the MNR that will be held for a long time.