handle additional DB closed message on DTO get

This commit is contained in:
James Seibel
2025-01-20 07:38:40 -06:00
parent f609dcb468
commit 582541d240
2 changed files with 13 additions and 2 deletions
@@ -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");
}
}
@@ -189,7 +189,15 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> 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;
}
}