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()); + } }