From f4bbd6f5c693f29fffc53df21e55fd7664e12bcf Mon Sep 17 00:00:00 2001 From: Stephan Brunner Date: Fri, 30 Apr 2021 22:49:37 +0200 Subject: [PATCH] [MongoDB Persistence] Do not use isConnected() to test the connection. The new method throws the real underlying exception instead of a generic one. This allows for detailed logging. Signed-off-by: Stephan Brunner --- .../mongodb/internal/MongoDBPersistenceService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bundles/org.openhab.persistence.mongodb/src/main/java/org/openhab/persistence/mongodb/internal/MongoDBPersistenceService.java b/bundles/org.openhab.persistence.mongodb/src/main/java/org/openhab/persistence/mongodb/internal/MongoDBPersistenceService.java index 4d4737f19919c..d40a825f8834f 100644 --- a/bundles/org.openhab.persistence.mongodb/src/main/java/org/openhab/persistence/mongodb/internal/MongoDBPersistenceService.java +++ b/bundles/org.openhab.persistence.mongodb/src/main/java/org/openhab/persistence/mongodb/internal/MongoDBPersistenceService.java @@ -264,9 +264,7 @@ private synchronized boolean tryConnectToDatabase() { // The mongo always succeeds in creating the connection. // We have to actually force it to test the connection to try to connect to the server. - if (!isConnected()) { - throw new RuntimeException("Failed to connect"); - } + cl.getAddress(); logger.debug("Connect MongoDB ... done"); return true;