lock.acquire(this, Lock.WRITE_LOCK); lock.enter(this);
lock.acquire(Lock.WRITE_LOCK);
	public void reindex(DocumentImpl oldDoc, DocumentImpl doc, NodeImpl node) {		int idxLevel = doc.reindexRequired();		if (idxLevel < 0) {			flush();			return;		}		oldDoc.setReindexRequired(idxLevel);		if (node == null)			LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId());		final long start = System.currentTimeMillis();		// remove dom index		Value ref = new NodeRef(doc.getDocId());		final IndexQuery query = new IndexQuery(null, IndexQuery.TRUNC_RIGHT, ref);		final Lock lock = domDb.getLock();		// try to acquire a lock on the file		try {			lock.acquire(this, Lock.WRITE_LOCK);			lock.enter(this);			domDb.setOwnerObject(this);			ArrayList nodes = domDb.findKeys(query);			long gid;			for (Iterator i = nodes.iterator(); i.hasNext();) {				ref = (Value) i.next();				gid = ByteConversion.byteToLong(ref.data(), 4);				if (oldDoc.getTreeLevel(gid) >= doc.reindexRequired()) {					if (node != null) {						if (XMLUtil.isDescendantOrSelf(oldDoc, node.getGID(), gid)) {							domDb.removeValue(ref);						}					} else						domDb.removeValue(ref);				}			}			//domDb.flush();		} catch (DBException e) {			LOG.warn("db error during reindex", e);		} catch (IOException e) {			LOG.warn("io error during reindex", e);		} catch (LockException e) {			// timed out			e.printStackTrace();			return;		} finally {			lock.release(this);		}		Iterator iterator;		if (node == null) {			NodeList nodes = doc.getChildNodes();			NodeImpl n;			for (int i = 0; i < nodes.getLength(); i++) {				n = (NodeImpl) nodes.item(i);				iterator = getDOMIterator(new NodeProxy(doc, n.getGID(), n.getInternalAddress()));				iterator.next();				scanNodes(iterator, n, "");			}		} else {			iterator = getDOMIterator(new NodeProxy(doc, node.getGID(), node.getInternalAddress()));			iterator.next();			scanNodes(iterator, node, node.getPath());		}		elementIndex.reindex(oldDoc, node);		textEngine.reindex(oldDoc, node);		doc.setReindexRequired(-1);		LOG.debug("reindex took " + (System.currentTimeMillis() - start) + "ms.");	}