Quote:
Remark: About from the obvious bug, the documentation of hibernate-search is not correct. It claims that running hibernate-search in the 'sync'-mode will be done in the main-Thread, which is definitely not the case.
Right I overlooked that sentence in the documentation; still the main thread is waiting for all subtasks to finish, so the behaviour is the same for you. I'll fix it but it should't matter.
Quote:
This is the preferred way to do this, but unfortunately the implementor forgot to call executor.shutdown() once the work is done. Here's what Joshua Bloch says in 'Effective Java - Item 68: Prefer executors and tasks to threads':
I didn't forget to close(), it would be silly if I had to create a new Executor for each job received by the backend, that doesn't scale. After each work is done, a new index change is likely to be submitted to the queue so the threads inside the Executor are reused. That's the whole point of using an Executor, and what Bloch means to say in his book (and also confirmed by "Java concurrency in practice", were Bloch is one of the authors).
So what I really need to do is close the Executor when I'm done with workqueues, this happens to be at SessionFactory/Application shutdown, so the code is correct.
As I said in my previous post I'm not very happy with people having to remember to close their SessionFactory, but that's recommended anyway so do it.
Quote:
You must keep on using the SessionFactory.close() hack till the issue is properly resolved (I'll put a bug in JIRA). This is, unless you want to recompile the fixed sources yourself, which is generally a bad idea. There is a slightly less aggressive solution, but that is really not so much different:
Hack? you're really supposed to close the resources you use, not to keep extra references around and mess with listeners.
As I said in previous post: frameworks (like Seam,Spring,Grails or managed EJB3) will do the housekeeping for you, but if you want to do it yourself you shouldn't blame the code when you forget.