Author: vgritsenko
Date: Tue Jun 26 17:25:22 2007
New Revision: 550995
URL: http://svn.apache.org/viewvc?view=rev&rev=550995
Log:
<action dev="VG" type="update" fixes-bug="42684" due-to="Natalia
Shilenkova">
Use Java NIO to lock database on startup.
</action>
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
xml/xindice/trunk/status.xml
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java?view=diff&rev=550995&r1=550994&r2=550995
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/Database.java Tue Jun 26
17:25:22 2007
@@ -348,18 +348,19 @@
}
// Put a lock (at least attempt to) on the database
- // FIXME: Use JDK1.4 FileLock
File lock = new File(getCollectionRoot(), "db.lock");
try {
- if (lock.exists() && !lock.delete()) {
- throw new IOException("Could not delete lock file.");
- }
this.lock = new FileOutputStream(lock);
- this.lock.write(new Date().toString().getBytes());
+
+ if (this.lock.getChannel().tryLock() != null) {
+ this.lock.write(new Date().toString().getBytes());
+ } else {
+ throw new IOException("Unable to acquire file lock.");
+ }
} catch (IOException e) {
throw new XindiceException("Unable to open lock file " + lock + ".
" +
- "Make sure database is not open by
another process. " +
- "Exception: " + e);
+ "Make sure database is not open by
another process.",
+ e);
}
// Now we are ready to open it up
Modified: xml/xindice/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=550995&r1=550994&r2=550995
==============================================================================
--- xml/xindice/trunk/status.xml (original)
+++ xml/xindice/trunk/status.xml Tue Jun 26 17:25:22 2007
@@ -117,6 +117,9 @@
<changes>
<release version="1.2" date="unreleased">
+ <action dev="VG" type="update" fixes-bug="42684" due-to="Natalia
Shilenkova">
+ Use Java NIO to lock database on startup.
+ </action>
<action dev="VG" type="add" fixes-bug="42478" due-to="Natalia
Shilenkova">
Add WebAdmin to the Xindice core (from scratchpad).
</action>