ensured single instance of vamsasarchive io handler to prevent lock contention.
[vamsas.git] / src / uk / ac / vamsas / client / simpleclient / SimpleClient.java
index ad74209..677094c 100644 (file)
@@ -321,20 +321,13 @@ public class SimpleClient implements IClient {
           _session.slog.warn("Session Document updated but may not be valid (false return from org.vamsas.simpleclient.ClientDocument.updateSessionDocument()");
         }
         log.debug("Document update successful.");
+        _session.setUnsavedFlag();
       }
       catch (IOException e) {
         log.warn("IO Problems when updating document!",e);
         _session.slog.error("IO problems when attempting to update document.");
       }
     }
-    try {
-      _session.setUnsavedFlag();
-      _session.unlockVamsasDocument();
-      evgen.enableDocumentWatch();
-    } catch (IOException e) {
-      log.warn("IO Problems when releasing lock on session document!",e);
-      _session.slog.error("IO problems when attempting to release lock on session document.");
-    }
     // garbage collect the ClientDocument instance.
     try {
       log.debug("Finalizing ClientDocument instance.");
@@ -343,6 +336,14 @@ public class SimpleClient implements IClient {
       log.error("Exception when trying to garbage collect ClientDocument for "+session.getSessionUrn(), e);
     }
     cdocument = null; // this is probably done by finalize
+
+    try {
+      _session.unlockVamsasDocument();
+      evgen.enableDocumentWatch();
+    } catch (IOException e) {
+      log.warn("IO Problems when releasing lock on session document!",e);
+      _session.slog.error("IO problems when attempting to release lock on session document.");
+    }
   }
   
   /*