{
if (indexInProgress)
{
// another thread is indexing, leave now
log.error("User attempted to kick off a reindexing of the search engine while it's already in progress.");
throw new ExecutionException("Cannot perform a reindexing right now - it's already in progress.");
}
// the indexing is not in progress - get a lock then start indexing
synchronized (indexInProgress)
{
// now that we have the lock - make sure it wasn't kicked off by
// another thread while we waited
if (indexInProgress)
{
log.error("User attempted to kick off a reindexing of the search engine while it's "
+ "already in progress. The other thread started while this one waited for the lock");
throw new ExecutionException("Cannot perform a reindexing right now - "
+ "it's already in progress, kicked off while we waited for the lock.");
}
indexInProgress = true;
}