From 582541d24050323167e810da882df3c0c0ca1930 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 20 Jan 2025 07:38:40 -0600 Subject: [PATCH] handle additional DB closed message on DTO get --- .../core/sql/DbConnectionClosedException.java | 5 ++++- .../distanthorizons/core/sql/repo/AbstractDhRepo.java | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/DbConnectionClosedException.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/DbConnectionClosedException.java index b4e8cffb0..d27a40071 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/DbConnectionClosedException.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/DbConnectionClosedException.java @@ -20,7 +20,10 @@ public class DbConnectionClosedException extends SQLException { // TODO long term we should prevent using repos that are closed, but for now this is the easier solution String message = e.getMessage().toLowerCase(); - return message.contains("connection closed") || message.contains("pointer is closed") || message.contains("database has been closed"); + return message.contains("connection closed") + || message.contains("pointer is closed") + || message.contains("stmt pointer is closed") + || message.contains("database has been closed"); } } 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 49aacfaf0..0559d7fd3 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 @@ -189,7 +189,15 @@ public abstract class AbstractDhRepo> implemen } catch (SQLException | IOException e) { - LOGGER.warn("Unexpected issue deserializing DTO ["+this.dtoClass.getSimpleName()+"] with primary key ["+primaryKey+"]. Error: ["+e.getMessage()+"].", e); + if (e instanceof SQLException + && DbConnectionClosedException.IsClosedException((SQLException)e)) + { + //LOGGER.warn("Attempted to get ["+this.dtoClass.getSimpleName()+"] with primary key ["+primaryKey+"] on closed repo ["+this.connectionString+"]."); + } + else + { + LOGGER.warn("Unexpected issue deserializing DTO ["+this.dtoClass.getSimpleName()+"] with primary key ["+primaryKey+"]. Error: ["+e.getMessage()+"].", e); + } return null; } }