use the getCanonicalPath() value to ensure valid pathnames being used on the platform. 

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1415725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-11-30 16:15:57 +00:00
parent c6cf88b836
commit 1288df5ad4
1 changed files with 11 additions and 9 deletions

View File

@ -20,14 +20,14 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import org.apache.activemq.util.IOHelper;
import org.apache.activemq.store.kahadb.disk.util.LinkedNode; import org.apache.activemq.store.kahadb.disk.util.LinkedNode;
import org.apache.activemq.store.kahadb.disk.util.SequenceSet; import org.apache.activemq.store.kahadb.disk.util.SequenceSet;
import org.apache.activemq.util.IOHelper;
/** /**
* DataFile * DataFile
* *
* *
*/ */
public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFile> { public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFile> {
@ -41,7 +41,7 @@ public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFil
this.dataFileId = Integer.valueOf(number); this.dataFileId = Integer.valueOf(number);
length = (int)(file.exists() ? file.length() : 0); length = (int)(file.exists() ? file.length() : 0);
} }
public File getFile() { public File getFile() {
return file; return file;
} }
@ -62,12 +62,13 @@ public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFil
length += size; length += size;
} }
public synchronized String toString() { @Override
public synchronized String toString() {
return file.getName() + " number = " + dataFileId + " , length = " + length; return file.getName() + " number = " + dataFileId + " , length = " + length;
} }
public synchronized RandomAccessFile openRandomAccessFile() throws IOException { public synchronized RandomAccessFile openRandomAccessFile() throws IOException {
return new RandomAccessFile(file, "rw"); return new RandomAccessFile(file.getCanonicalPath(), "rw");
} }
public synchronized void closeRandomAccessFile(RandomAccessFile file) throws IOException { public synchronized void closeRandomAccessFile(RandomAccessFile file) throws IOException {
@ -77,7 +78,7 @@ public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFil
public synchronized boolean delete() throws IOException { public synchronized boolean delete() throws IOException {
return file.delete(); return file.delete();
} }
public synchronized void move(File targetDirectory) throws IOException{ public synchronized void move(File targetDirectory) throws IOException{
IOHelper.moveFile(file,targetDirectory); IOHelper.moveFile(file,targetDirectory);
} }
@ -85,8 +86,9 @@ public class DataFile extends LinkedNode<DataFile> implements Comparable<DataFil
public SequenceSet getCorruptedBlocks() { public SequenceSet getCorruptedBlocks() {
return corruptedBlocks; return corruptedBlocks;
} }
public int compareTo(DataFile df) { @Override
public int compareTo(DataFile df) {
return dataFileId - df.dataFileId; return dataFileId - df.dataFileId;
} }