From 63d6d42356b462a71e5e8d600498297c7fe68787 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 22 Mar 2026 21:36:31 -0500 Subject: [PATCH] ignore already closed repo close calls --- .../core/sql/repo/AbstractDhRepo.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/AbstractDhRepo.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/AbstractDhRepo.java index 2c1733665..67f96ab08 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/AbstractDhRepo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/AbstractDhRepo.java @@ -25,9 +25,11 @@ import com.seibel.distanthorizons.core.sql.DatabaseUpdater; import com.seibel.distanthorizons.core.sql.DbConnectionClosedException; import com.seibel.distanthorizons.core.sql.dto.IBaseDTO; import com.seibel.distanthorizons.core.sql.repo.phantoms.AutoClosableTrackingWrapper; +import com.seibel.distanthorizons.core.util.ExceptionUtil; import com.seibel.distanthorizons.core.util.KeyedLockContainer; import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.core.logging.DhLogger; +import com.seibel.distanthorizons.coreapi.util.StringUtil; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -496,20 +498,12 @@ public abstract class AbstractDhRepo> implemen Connection connection = CONNECTIONS_BY_CONNECTION_STRING.remove(connectionString); if (connection != null) { + // don't try closing an already closed connection if (!connection.isClosed()) { LOGGER.info("Closing database connection: [" + connectionString + "]"); connection.close(); } - else - { - // these warnings can be ignored in release builds, as long as the connection is closed it doesn't really matter - // TODO fix duplicate closes - if (ModInfo.IS_DEV_BUILD) - { - LOGGER.warn("Attempting to close already closed database connection: [" + connectionString + "]"); - } - } } } catch(SQLException e) @@ -560,22 +554,13 @@ public abstract class AbstractDhRepo> implemen LOGGER.warn(stringBuilder.toString()); } - + // don't try closing an already closed connection if (!this.connection.isClosed()) { LOGGER.info("Closing database connection: [" + this.connectionString + "]..."); this.connection.close(); LOGGER.info("Finished closing database connection: [" + this.connectionString + "]"); } - else - { - // these warnings can be ignored in release builds, as long as the connection is closed it doesn't really matter - // TODO fix duplicate closes - if (ModInfo.IS_DEV_BUILD) - { - LOGGER.warn("Attempting to close already closed database connection: [" + this.connectionString + "]"); - } - } } ACTIVE_CONNECTION_STRINGS_BY_REPO.remove(this); }