MODE-1190 Corrected reloading of node types upon restart #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've finally replicated the problem and identified a fix. Normally when restarting the engine reads the node types from the system store, and these node types are usually in a specific order. Somehow, the node types are reordered so that the built-ins are not first in the list, and when registering these the built-ins (often "nt:unstructured" or "nt:base") are not able to be resolved. Fixing the ordering won't help with existing installations, so instead I chose to change RepositoryNodeTypeManager to be more tolerant of the order of the node types by simply iterating multiple times through the list and only failing when no more node types can be successfully registered.
In addition to the change to RepositoryNodeTypeManager, the bulk of the rest of the changes are new (manual) integration tests that are successful at replicating the problem. (Note that I was not able to replicate the problem when restarting the engine while in the same process - only when restarting ModeShape in a separate VM.)
All unit and integration tests pass, as does the new manual test.