: Recently I was writing a SearchComponent which works only in a distributed : context. In the prepare method it alters some static state, and then : reverts that modification during one of the calls to finishStage. However, : I realized that if an exception is thrown by another SearchComponent, the : change is never reverted and my state becomes "corrupted" and doesn't : reflect the reality. : To solve this, I thought about adding an "onException" method to the : SearchComponent class, and make appropriate modifications in SearchHandler : to support it. Such a change would allow SearchComponent to clean up after : themselves in a case of exceptions. What do you think?
you really, REALLY, don't want to be modifying static state in a SearchCOmponent or RequestHandler -- not "java definition of static variable" or even "object instance variable state" on the components/handlers themselves. SearchComponent and RequestHandler instances are re-used in parallel threads processing concurrent requests -- so any "state" you mutate on them will poluate the results of other requests happening at the same time. If you have state you want to track between prepare/process/finishStage you should absolutely use the ResponseBuilder and/or SolrQueryRequest for this. SolrQueryRequest.getContext() exists explicitly for third-party custom plugins to track state like you're describing. -Hoss http://www.lucidworks.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
