The thing is that we were at that position already, before I changed it so that MP requires writer up front. The reason was, like Mike mentioned, that writer had to be passed on all method calls, for really no good reason. A MP is usually coupled w/ an IW instance and I don't think we should opt for decoupling them.
Most of this patch removes MP setting from IW to IWC (and hence changes test code to use the new API). The SetOnce juggling is done only to ensure an IW is set exactly once on MP, and allows us to resolve that circular dependency. We can do two things:
- Continue w/ SetOnce as introduced in this patch.
- Introduce a setIndexWriter on MP which anyone can call, even more than once.
With (1) I don't think we complicate anything, and SetOnce can be useful in other places as well. (2) is really like passing writer on all method calls, so let's at least not have it as part of all methods signature. I prefer (1) slightly over (2) but am fine w/ (2) as well. I wouldn't want to change MP back to require IW on all its methods.