locking for windows (XP) partly debugged. ClientsFileTest watchers do not behave...
[vamsas.git] / src / org / vamsas / client / simpleclient / ClientsFile.java
index 598bfdd..d8abd2b 100644 (file)
@@ -43,8 +43,8 @@ public class ClientsFile extends ListFile {
       try {
         ClientHandle[] clients=null;
         if (this.fileLock.rafile.length()>0) {
-          ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(
-              new java.io.FileInputStream(sessionFile)));
+          
+          ObjectInputStream is = new ObjectInputStream(fileLock.getBufferedInputStream(true));
           Object o;
           o=is.readObject();
           if (o!=null) {
@@ -231,11 +231,14 @@ public class ClientsFile extends ListFile {
       File templist = backupSessionFile();
       if (templist != null) {
         try {
-          fileLock.rafile.setLength(0);
-          ObjectOutputStream os = new ObjectOutputStream(
-              new BufferedOutputStream(new FileOutputStream(this.sessionFile)));
+          // fileLock.rafile.setLength(0);
+          ObjectOutputStream os = 
+            new ObjectOutputStream(fileLock.getBufferedOutputStream(true));
+          
+//              new BufferedOutputStream(new FileOutputStream(this.sessionFile)));
+          //    new BufferedOutputStream(new FileOutputStream(this.fileLock.rafile.getFD())));
           os.writeObject(clients);
-          os.close();
+          os.close(); // close destroys lock!
           // All done - remove the backup.
           templist.delete();
           templist = null;