diff --git a/src/main/java/io/supertokens/storage/postgresql/Start.java b/src/main/java/io/supertokens/storage/postgresql/Start.java index 6bfc32ba..e10ecda7 100644 --- a/src/main/java/io/supertokens/storage/postgresql/Start.java +++ b/src/main/java/io/supertokens/storage/postgresql/Start.java @@ -556,6 +556,9 @@ public void deleteAllInformation() throws StorageQueryException { // this can happen if the db being connected to is not actually present. // So we ignore this since there are tests in which we are adding a non existent db for a tenant, // and we want to not throw errors in the next test wherein this function is called. + } else if (e.getMessage() != null && e.getMessage().contains("has been closed")) { + // this can happen if the connection pool was already closed, e.g. due to a race condition + // during test teardown where a background thread closed the pool. It's safe to ignore. } else { throw new StorageQueryException(e); } diff --git a/src/test/java/io/supertokens/storage/postgresql/test/TestingProcessManager.java b/src/test/java/io/supertokens/storage/postgresql/test/TestingProcessManager.java index 7c82f52f..64545625 100644 --- a/src/test/java/io/supertokens/storage/postgresql/test/TestingProcessManager.java +++ b/src/test/java/io/supertokens/storage/postgresql/test/TestingProcessManager.java @@ -137,8 +137,10 @@ public void kill(boolean removeAllInfo) throws InterruptedException { try { main.deleteAllInformationForTesting(); } catch (Exception e) { - if (!e.getMessage().contains("Please call initPool before getConnection")) { - // we ignore this type of message because it's due to tests in which the init failed + if (e.getMessage() != null && + !e.getMessage().contains("Please call initPool before getConnection") && + !e.getMessage().contains("has been closed")) { + // we ignore these types of messages because they are due to tests in which the init failed // and here we try and delete assuming that init had succeeded. throw new RuntimeException(e); }