From: Wolfgang M. M. <wol...@us...> - 2004-06-16 09:19:35
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32310/src/org/exist/collections Modified Files: Collection.java Log Message: Lock not removed when updating an existing document if the new document has been invalid. Index: Collection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/Collection.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Collection.java 8 Jun 2004 08:16:14 -0000 1.28 --- Collection.java 16 Jun 2004 09:19:26 -0000 1.29 *************** *** 719,722 **** --- 719,723 ---- throw new PermissionDeniedException("The document is locked by user " + lockUser.getName()); + // check if the document is currently being changed by someone else Lock oldLock = oldDoc.getUpdateLock(); *************** *** 835,838 **** --- 836,851 ---- if (trigger != null) trigger.setValidating(false); + } catch(EXistException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(SAXException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(PermissionDeniedException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(TriggerException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; } finally { lock.release(); *************** *** 842,846 **** // second pass: store the document ! LOG.debug("storing document ..."); try { try { --- 855,859 ---- // second pass: store the document ! LOG.debug("storing document " + document.getDocId() + " ..."); try { try { *************** *** 868,872 **** } broker.deleteObservers(); - System.out.println(this); return document; } --- 881,884 ---- *************** *** 884,888 **** if (broker.isReadOnly()) throw new PermissionDeniedException("Database is read-only"); ! DocumentImpl document, oldDoc = null; XMLReader reader; try { --- 896,900 ---- if (broker.isReadOnly()) throw new PermissionDeniedException("Database is read-only"); ! DocumentImpl document = null, oldDoc = null; XMLReader reader; try { *************** *** 913,916 **** --- 925,929 ---- throw new PermissionDeniedException( "Not allowed to write to collection " + getName()); + // if an old document exists, save the new document with a temporary // document name *************** *** 1010,1013 **** --- 1023,1038 ---- if (trigger != null) trigger.setValidating(false); + } catch(EXistException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(SAXException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(PermissionDeniedException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(TriggerException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; } finally { lock.release(); *************** *** 1182,1185 **** --- 1207,1222 ---- if (trigger != null) trigger.setValidating(false); + } catch(EXistException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(SAXException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(PermissionDeniedException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; + } catch(TriggerException e) { + if(oldDoc != null) oldDoc.getUpdateLock().release(Lock.WRITE_LOCK); + throw e; } finally { lock.release(); |