karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1529090 - /karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java
Date Fri, 04 Oct 2013 07:10:13 GMT
Author: gnodet
Date: Fri Oct  4 07:10:12 2013
New Revision: 1529090

URL: http://svn.apache.org/r1529090
Log:
[KARAF-2500] Karaf should monitor the lock file existence

Modified:
    karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java

Modified: karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java?rev=1529090&r1=1529089&r2=1529090&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java
(original)
+++ karaf/branches/karaf-2.3.x/main/src/main/java/org/apache/karaf/main/SimpleFileLock.java
Fri Oct  4 07:10:12 2013
@@ -30,6 +30,7 @@ public class SimpleFileLock implements L
     private static final Logger LOG = Logger.getLogger(SimpleFileLock.class.getName());
     private static final String PROPERTY_LOCK_DIR = "karaf.lock.dir";
     private static final String PROP_KARAF_BASE = "karaf.base";
+    private File file;
     private RandomAccessFile lockFile;
     private FileLock lock;
 
@@ -46,8 +47,8 @@ public class SimpleFileLock implements L
                 props.setProperty(PROPERTY_LOCK_DIR, System.getProperty(PROP_KARAF_BASE));
             }
 
-            File base = new File(props.getProperty(PROPERTY_LOCK_DIR));
-            lockFile = new RandomAccessFile(new File(base, "lock"), "rw");
+            file = new File(props.getProperty(PROPERTY_LOCK_DIR), "lock");
+            lockFile = new RandomAccessFile(file, "rw");
         } catch (IOException ioe){
             throw new RuntimeException("Karaf can't startup, make sure the log file can be
accessed and written by the user starting Karaf : " + ioe.getMessage());
         } catch (Exception e){
@@ -73,7 +74,7 @@ public class SimpleFileLock implements L
     }
  
     public boolean isAlive() throws Exception {
-        return lock != null;
+        return lock != null && lock.isValid() && file.exists();
     }
 
     private static File getKarafLock(File lock,Properties props) {



Mime
View raw message