View | Details | Raw Unified | Return to bug 42684
Collapse All | Expand All

(-)java/src/org/apache/xindice/core/Database.java (-5 / +6 lines)
Lines 348-361 Link Here
348
        }
348
        }
349
349
350
        // Put a lock (at least attempt to) on the database
350
        // Put a lock (at least attempt to) on the database
351
        // FIXME: Use JDK1.4 FileLock
352
        File lock = new File(getCollectionRoot(), "db.lock");
351
        File lock = new File(getCollectionRoot(), "db.lock");
353
        try {
352
        try {
354
            if (lock.exists() && !lock.delete()) {
353
            this.lock = new FileOutputStream(lock);
355
                throw new IOException("Could not delete lock file.");
354
355
            if (this.lock.getChannel().tryLock() != null) {
356
                this.lock.write(new Date().toString().getBytes());
357
            } else {
358
                throw new IOException("Unable to acquire file lock.");
356
            }
359
            }
357
            this.lock = new FileOutputStream(lock);
358
            this.lock.write(new Date().toString().getBytes());
359
        } catch (IOException e) {
360
        } catch (IOException e) {
360
            throw new XindiceException("Unable to open lock file " + lock + ". " +
361
            throw new XindiceException("Unable to open lock file " + lock + ". " +
361
                                       "Make sure database is not open by another process. " +
362
                                       "Make sure database is not open by another process. " +

Return to bug 42684