Author: ssmiweve
Date: 2008-12-03 13:11:41 +0100 (Wed, 03 Dec 2008)
New Revision: 7018

Modified:
   
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
Log:
broaden synchronisation beyond the channel.close()

java.nio.channels.OverlappingFileLockException
        at 
sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1173)
        at 
sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1075)
        at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:837)
        at java.nio.channels.FileChannel.lock(FileChannel.java:860)
        at 
no.sesat.search.http.filters.SiteJspLoaderFilter.downloadJsp(SiteJspLoaderFilter.java:211)
        at 
no.sesat.search.http.filters.SiteJspLoaderFilter.doFilter(SiteJspLoaderFilter.java:104)

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-03 11:57:42 UTC (rev 7017)
+++ 
branches/2.18/war/src/main/java/no/sesat/search/http/filters/SiteJspLoaderFilter.java
       2008-12-03 12:11:41 UTC (rev 7018)
@@ -199,15 +199,15 @@
                 final RandomAccessFile fileAccess = new RandomAccessFile(file, 
"rw");
                 final FileChannel channel = fileAccess.getChannel();
 
-                try{
-                    // channel.lock() only synchronises file access between 
programs, but not between threads inside
-                    //  the current JVM. The latter results in the 
OverlappingFileLockException.
-                    //  At least this is my current understanding of 
java.nio.channels
-                    //   It may be that no synchronisation or locking is 
required at all. A beer to whom answers :-)
-                    // So we must provide synchronisation between our own 
threads,
-                    //  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()){
+                // channel.lock() only synchronises file access between 
programs, but not between threads inside
+                //  the current JVM. The latter results in the 
OverlappingFileLockException.
+                //  At least this is my current understanding of 
java.nio.channels
+                //   It may be that no synchronisation or locking is required 
at all. A beer to whom answers :-)
+                // So we must provide synchronisation between our own threads,
+                //  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()){
+                    try{
                         channel.lock();
 
                         if(fileExisted){
@@ -226,11 +226,11 @@
                             file.deleteOnExit();
 
                         }
+                    }finally{
+                        channel.close();
+                        LOG.debug("resource created as " + 
config.getServletContext().getResource(jsp));
+
                     }
-                }finally{
-                    channel.close();
-                    LOG.debug("resource created as " + 
config.getServletContext().getResource(jsp));
-
                 }
 
             }catch (IOException ex) {

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to