Handle the OverlappingFileLockException that could occur.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@619511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-02-07 17:13:03 +00:00
parent 52ca2de3f0
commit 939a3160f3
1 changed files with 7 additions and 1 deletions

View File

@ -20,8 +20,10 @@ import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
import org.apache.activemq.util.ByteSequence;
import org.apache.activemq.util.IOExceptionSupport;
/**
* Use to reliably store fixed sized state data. It stores the state in record
@ -72,7 +74,11 @@ public final class ControlFile {
}
if (lock == null) {
lock = randomAccessFile.getChannel().tryLock();
try {
lock = randomAccessFile.getChannel().tryLock();
} catch (OverlappingFileLockException e) {
throw IOExceptionSupport.create("Control file '" + file + "' could not be locked.",e);
}
if (lock == null) {
throw new IOException("Control file '" + file + "' could not be locked.");
}