From b36a1058d4584adca399a591c4109866d4265e07 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Fri, 24 Aug 2018 14:24:25 +0100 Subject: [PATCH] ARTEMIS-2056 Set write position on JDBCFile copy --- .../artemis/jdbc/store/file/JDBCSequentialFile.java | 6 ++++++ .../artemis/jdbc/file/JDBCSequentialFileFactoryTest.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java index 843be545d8..fec8eaf7bf 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java @@ -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); diff --git a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java index d567f84eb9..a45b9a81d3 100644 --- a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java +++ b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java @@ -221,6 +221,9 @@ public class JDBCSequentialFileFactoryTest { checkData(file, src); checkData(copy, src); + + assertEquals(bufferSize, copy.size()); + assertEquals(bufferSize, file.size()); } @Test