Author: ssmiweve
Date: 2008-12-13 23:00:06 +0100 (Sat, 13 Dec 2008)
New Revision: 7080
Modified:
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
Log:
always close the RandomAccessFile
Modified:
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
===================================================================
---
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
2008-12-12 15:40:31 UTC (rev 7079)
+++
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
2008-12-13 22:00:06 UTC (rev 7080)
@@ -196,8 +196,6 @@
if(!fileExisted){
file.createNewFile();
}
- final RandomAccessFile fileAccess = new RandomAccessFile(file,
"rw");
- final FileChannel channel = fileAccess.getChannel();
// channel.lock() only synchronises file access between
programs, but not between threads inside
// the current JVM. The latter results in the
OverlappingFileLockException.
@@ -207,7 +205,15 @@
// synchronisation against the file's path (using the JVM's
String.intern() functionality)
// should work. (I can't imagine this string be used for any
other synchronisation purposes).
synchronized(file.toString().intern()){
+
+ RandomAccessFile fileAccess = null;
+ FileChannel channel = null;
+
try{
+
+ fileAccess = new RandomAccessFile(file, "rws");
+ channel = fileAccess.getChannel();
+
channel.lock();
if(fileExisted){
@@ -222,14 +228,13 @@
if(needsUpdating){
// download file from skin
channel.write(ByteBuffer.wrap(golden), 0);
- channel.force(true);
file.deleteOnExit();
-
}
}finally{
- channel.close();
+ if(null != channel){ channel.close(); }
+ if(null != fileAccess){ fileAccess.close(); }
+
LOG.debug("resource created as " +
config.getServletContext().getResource(jsp));
-
}
}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits