ARTEMIS-2056 Set write position on JDBCFile copy

This commit is contained in:
Martyn Taylor 2018-08-24 14:24:25 +01:00
parent 490ef71e1d
commit b36a1058d4
2 changed files with 9 additions and 0 deletions

View File

@ -330,6 +330,7 @@ public class JDBCSequentialFile implements SequentialFile {
public SequentialFile cloneFile() {
try {
JDBCSequentialFile clone = new JDBCSequentialFile(fileFactory, filename, executor, dbDriver, writeLock);
clone.setWritePosition(this.writePosition);
return clone;
} catch (Exception e) {
fileFactory.onIOError(e, "Error cloning JDBC file.", this);
@ -342,8 +343,13 @@ public class JDBCSequentialFile implements SequentialFile {
JDBCSequentialFile clone = (JDBCSequentialFile) cloneFile;
try {
synchronized (writeLock) {
if (logger.isTraceEnabled()) {
logger.trace("JDBC Copying File. From: " + this + " To: " + cloneFile);
}
clone.open();
dbDriver.copyFileData(this, clone);
clone.setWritePosition(writePosition);
}
} catch (Exception e) {
fileFactory.onIOError(e, "Error copying JDBC file.", this);

View File

@ -221,6 +221,9 @@ public class JDBCSequentialFileFactoryTest {
checkData(file, src);
checkData(copy, src);
assertEquals(bufferSize, copy.size());
assertEquals(bufferSize, file.size());
}
@Test