Thanks for the review!
1) I don't understand the need for the CLOSE_LOCK, can you explain?
Just so that only one thread will actually do the close logic. You can close an IndexWriter with either rollback or close and one of those might internally call the other - so the CLOSE_LOCK just makes sure the SolrIndexWriter close logic happens once. We don't use the this lock just so that we don't end up conflicting with other uses.
2) In DirectUpdateHandler2 why the change from writer.shutdown() to writer.close()? All the other changes go in the other direction, e.g. close -> shutdown.
Because shutdown will wait for merges and commit, etc and DirectUpdateHandler2 actually does that right above - optionally - it was actually a small bug that someone changed it to shutdown (that's just on branch 5x though). We didn't want to commit in all cases like shutdown was doing.
I do see a problem though - we need to call waitForMerges before we close.