From 0c52c4b4bfd72378cfe242cd9b27f10a86a4ed04 Mon Sep 17 00:00:00 2001 From: Fabio Scippacercola Date: Wed, 22 May 2024 19:13:31 +0200 Subject: [PATCH] fix: logging of connection failures due to bad evaluation of a string comparison --- .../conductor/postgres/util/PostgresQueueListener.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/postgres-persistence/src/main/java/com/netflix/conductor/postgres/util/PostgresQueueListener.java b/postgres-persistence/src/main/java/com/netflix/conductor/postgres/util/PostgresQueueListener.java index 4fcbe5326..e0a99beda 100644 --- a/postgres-persistence/src/main/java/com/netflix/conductor/postgres/util/PostgresQueueListener.java +++ b/postgres-persistence/src/main/java/com/netflix/conductor/postgres/util/PostgresQueueListener.java @@ -166,7 +166,7 @@ private void requestStats() { conn.setAutoCommit(previousAutoCommitMode); } } catch (SQLException e) { - if (!e.getSQLState().equals("08003")) { + if (!isSQLExceptionConnectionDoesNotExists(e)) { logger.error("Error fetching notifications {}", e.getSQLState()); } connect(); @@ -187,7 +187,7 @@ private void handleNotifications() { } processPayload(notifications[notifications.length - 1].getParameter()); } catch (SQLException e) { - if (e.getSQLState() != "08003") { + if (!isSQLExceptionConnectionDoesNotExists(e)) { logger.error("Error fetching notifications {}", e.getSQLState()); } connect(); @@ -223,4 +223,8 @@ private void processPayload(String payload) { throw new RuntimeException(e); } } + + private static boolean isSQLExceptionConnectionDoesNotExists(SQLException e) { + return "08003".equals(e.getSQLState()); + } }