ModeShape/modeshape — pull request #717 by rhauch (2013-02-26 23:41:11+00:00)
Title: MODE-1830 Corrected the purging of workspace caches in a cluster

_This should be merged into the '3.1.x' branch and cherry-picked into the 'master' branch.

Before this fix, when a change was made via a WritableSessionCache, any changes persisted to the store were also used to directly purge any previously-cached node representations from the corresponding WorkspaceCache. Thus, when the RepositoryCache received the changes, it simply forwarding them to all workspaces except the one in which the changes originated.

However, in a clustered environment, the changes originate on one process and are sent to all other processes. The logic described above works fine in the same process in which the changes originated, but it doesn't correctly propagate the changes in the other processes.

The fix was pretty simple: determine if the changes came from the same process. If so, the use the current logic. If not, always forward the changes to all WorkspaceCache instances.

I also modified the ClusteredRepositoryTest to look in process A for nodes changed in process B. This failed before the logic was fixed, and now works with the fix.