Skip to content

Commit

Permalink
prevent orientdb NPE on warning message on init (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximthomas authored May 20, 2024
1 parent 54dae00 commit bf79ee4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public synchronized static ODatabaseDocumentPool getPool(String dbURL, String us
ODatabaseDocumentTx setupDbConn = null;
ODatabaseDocumentPool pool;
try {
OLogManager.instance().setWarnEnabled(false);
if (Double.parseDouble(System.getProperty("java.specification.version")) >= 15) {
OLogManager.instance().setWarnEnabled(false);
}
if (setupDB) {
logger.debug("Check DB exists in expected state for pool {}", dbURL);
setupDbConn = checkDB(dbURL, user, password, completeConfig);
Expand All @@ -108,7 +110,9 @@ public synchronized static ODatabaseDocumentPool getPool(String dbURL, String us
pools.put(dbURL, pool);
}
} finally {
OLogManager.instance().setWarnEnabled(true);
if (Double.parseDouble(System.getProperty("java.specification.version")) >= 15) {
OLogManager.instance().setWarnEnabled(true);
}
if (setupDbConn != null) {
setupDbConn.activateOnCurrentThread();
setupDbConn.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.forgerock.json.JsonValue.json;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.schema.OType;
Expand Down Expand Up @@ -59,7 +60,13 @@ public class DocumentUtilTest {

@BeforeClass
public void init() throws Exception {
if (Double.parseDouble(System.getProperty("java.specification.version")) >= 15) {
OLogManager.instance().setWarnEnabled(false);
}
db = new ODatabaseDocumentTx(dbURL);
if (Double.parseDouble(System.getProperty("java.specification.version")) >= 15) {
OLogManager.instance().setWarnEnabled(true);
}
if (!db.exists()) {
db.create();
} else {
Expand Down

0 comments on commit bf79ee4

Please sign in to comment.