From aea108ba2b5f22cf5615bd02d719786e84d359da Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 24 Jan 2012 21:35:01 +0000 Subject: Fix race condition when making initial connection to a slow database. --- .../com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/amazon/carbonado/repo') diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java index 5ac62e3..b98993e 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java @@ -85,6 +85,9 @@ public class JDBCRepositoryBuilder extends AbstractRepositoryBuilder { public Repository build(AtomicReference rootRef) throws RepositoryException { assertReady(); + + final Repository originalRoot = rootRef.get(); + JDBCRepository repo = new JDBCRepository (rootRef, getName(), isMaster(), getTriggerFactories(), getDataSource(), getDataSourceCloseOnShutdown(), @@ -94,7 +97,10 @@ public class JDBCRepositoryBuilder extends AbstractRepositoryBuilder { getSuppressReloadMap(), mSequenceSelectStatement, mForceStoredSequence, mPrimaryKeyCheckDisabled, mResolver); - rootRef.set(repo); + + // Don't wipe out root when using BelatedRepositoryCreator. + rootRef.compareAndSet(originalRoot, repo); + return repo; } -- cgit v1.2.3