LOG.debug(e.getMessage(), e);
	public void removeDocument(DocumentImpl doc) {		try {			TreeSet words = new TreeSet();			NodeList children = doc.getChildNodes();			NodeImpl node;			for (int i = 0; i < children.getLength(); i++) {				node = (NodeImpl) children.item(i);				Iterator j = broker.getDOMIterator(new NodeProxy(doc, node						.getGID(), node.getInternalAddress()));				collect(words, j);			}			String word;			Value val;			WordRef ref;			VariableByteInput is = null;			VariableByteOutputStream os;			int len;			int docId;			long delta;			byte section;			short collectionId = doc.getCollection().getId();			boolean changed;			Lock lock = dbWords.getLock();			for (Iterator iter = words.iterator(); iter.hasNext();) {				word = (String) iter.next();				ref = new WordRef(collectionId, word);				try {					lock.acquire(Lock.READ_LOCK);					is = dbWords.getAsStream(ref);				} catch (LockException e) {                    LOG.warn("removeDocument(DocumentImpl) - "                        + "could not acquire lock on words db", e);					is = null;				} catch (IOException e) {                    LOG.error("removeDocument(DocumentImpl) - "                        + "io error while reading words", e);					is = null;				} finally {					lock.release();				}				if (is == null)					continue;				os = new VariableByteOutputStream();				changed = false;				try {					while (is.available() > 0) {						docId = is.readInt();						section = is.readByte();						len = is.readInt();						if (docId != doc.getDocId()) {							// copy data to new buffer							os.writeInt(docId);							os.writeByte(section);							os.writeInt(len);							is.copyTo(os, len);						} else {							changed = true;							// skip							is.skip(len);						}					}				} catch (EOFException e) {				} catch (IOException e) {				}				if (changed) {					try {						lock.acquire(Lock.WRITE_LOCK);						if (os.data().size() == 0) {							dbWords.remove(ref);						} else {							if (dbWords.put(ref, os.data()) < 0)                                if (LOG.isDebugEnabled()) {                                    LOG.debug("removeDocument() - "                                        + "could not remove index for "                                        + word);                                }						}					} catch (LockException e) {                        LOG.warn("removeDocument(DocumentImpl) - "                            + "could not acquire lock on words db", e);					} finally {						lock.release();					}				}			}            if (LOG.isDebugEnabled()) {                LOG.debug("removeDocument() - "                    + words.size()                    + " words updated.");            }		} catch (ReadOnlyException e) {            LOG.warn("removeDocument(DocumentImpl) - "                + "database is read-only");		}	}