Make OpenFile Thread Safe
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/af90bc5f Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/af90bc5f Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/af90bc5f Branch: refs/heads/master Commit: af90bc5f435c8e8acaa524602067dbbc5606a662 Parents: f346347 Author: Martyn Taylor <[email protected]> Authored: Wed Aug 1 17:54:35 2018 +0100 Committer: andytaylor <[email protected]> Committed: Fri Aug 10 13:35:23 2018 +0100 ---------------------------------------------------------------------- .../store/file/JDBCSequentialFileFactoryDriver.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/af90bc5f/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java ---------------------------------------------------------------------- diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java index 14ad25e..e736dca 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java @@ -108,12 +108,14 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { * @throws SQLException */ public void openFile(JDBCSequentialFile file) throws SQLException { - final long fileId = fileExists(file); - if (fileId < 0) { - createFile(file); - } else { - file.setId(fileId); - loadFile(file); + synchronized (connection) { + final long fileId = fileExists(file); + if (fileId < 0) { + createFile(file); + } else { + file.setId(fileId); + loadFile(file); + } } }
