try
{
- file.createNewFile();
lock.openLock( false, timeout > 0 );
acquired = true;
}
+ catch ( FileNotFoundException e )
+ {
+ // can happen if an other thread has deleted the file
+ log.debug( "read Lock skip: {} try to create file", e.getMessage() );
+ createNewFileQuietly( file );
+ }
catch ( IOException e )
{
throw new FileLockException( e.getMessage(), e );
lock.openLock( true, timeout > 0 );
acquired = true;
}
+ catch ( FileNotFoundException e )
+ {
+ // can happen if an other thread has deleted the file
+ log.debug( "write Lock skip: {} try to create file", e.getMessage() );
+ createNewFileQuietly( file );
+ }
catch ( IOException e )
{
throw new FileLockException( e.getMessage(), e );
return lock;
}
- catch ( FileNotFoundException e )
+
+ catch (
+
+ FileNotFoundException e
+
+ )
+
{
throw new FileLockException( e.getMessage(), e );
}
}
+ private void createNewFileQuietly( File file )
+ {
+ try
+ {
+ file.createNewFile();
+ }
+ catch ( IOException e )
+ {
+ // skip that
+ }
+ }
+
@Override
public void release( Lock lock )
throws FileLockException