diff --git a/src/main/java/io/ebean/Ebean.java b/src/main/java/io/ebean/Ebean.java index edb4a5d6f..df48ce3ba 100644 --- a/src/main/java/io/ebean/Ebean.java +++ b/src/main/java/io/ebean/Ebean.java @@ -5,10 +5,10 @@ import io.ebean.cache.ServerCacheManager; import io.ebean.config.ServerConfig; import io.ebean.text.csv.CsvReader; import io.ebean.text.json.JsonContext; -import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; import java.util.Collection; @@ -131,8 +131,7 @@ public final class Ebean { private final ConcurrentHashMap concMap = new ConcurrentHashMap<>(); /** - * Cache for synchronized read, creation and put. Protected by the monitor - * object. + * Cache for synchronized read, creation and put. Protected by the monitor object. */ private final HashMap syncMap = new HashMap<>(); @@ -146,14 +145,7 @@ public final class Ebean { private ServerManager() { try { - // skipDefaultServer is set by EbeanServerFactory - // ... when it is creating the primaryServer - if (PrimaryServer.isSkip()) { - // primary server being created by EbeanServerFactory - // ... so we should not try and create it here - logger.debug("PrimaryServer.isSkip()"); - - } else { + if (!PrimaryServer.isSkip()) { // look to see if there is a default server defined String defaultName = PrimaryServer.getDefaultServerName(); logger.debug("defaultName:{}", defaultName); diff --git a/src/main/java/io/ebean/EbeanServerFactory.java b/src/main/java/io/ebean/EbeanServerFactory.java index 090e23e9a..888b54647 100644 --- a/src/main/java/io/ebean/EbeanServerFactory.java +++ b/src/main/java/io/ebean/EbeanServerFactory.java @@ -65,10 +65,8 @@ public class EbeanServerFactory { EbeanServer server = createInternal(config); - if (config.isDefaultServer()) { - PrimaryServer.setSkip(true); - } if (config.isRegister()) { + PrimaryServer.setSkip(true); Ebean.register(server, config.isDefaultServer()); } diff --git a/src/test/java/io/ebean/PrimaryServerTest.java b/src/test/java/io/ebean/PrimaryServerTest.java index ce5a198dd..56460f7f3 100644 --- a/src/test/java/io/ebean/PrimaryServerTest.java +++ b/src/test/java/io/ebean/PrimaryServerTest.java @@ -14,7 +14,7 @@ public class PrimaryServerTest extends BaseTestCase { @Test - public void testIsSkipPrimaryServer() throws Exception { + public void testIsSkipPrimaryServer() { PrimaryServer.setSkip(true); assertTrue(PrimaryServer.isSkip()); PrimaryServer.setSkip(false); @@ -23,14 +23,14 @@ public class PrimaryServerTest extends BaseTestCase { @Test @ForPlatform(Platform.H2) - public void testGetPrimaryServerName() throws Exception { + public void testGetPrimaryServerName() { String primaryServerName = PrimaryServer.getDefaultServerName(); assertEquals("h2", primaryServerName); } @Test - public void testLoadProperties() throws Exception { + public void testLoadProperties() { Properties properties = PrimaryServer.getProperties(); assertTrue(!properties.isEmpty());