Skip to content

Commit

Permalink
fix: logging of connection failures due to bad evaluation of a string…
Browse files Browse the repository at this point in the history
… comparison
  • Loading branch information
Fabio Scippacercola committed May 22, 2024
1 parent 31e2024 commit 0c52c4b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -223,4 +223,8 @@ private void processPayload(String payload) {
throw new RuntimeException(e);
}
}

private static boolean isSQLExceptionConnectionDoesNotExists(SQLException e) {
return "08003".equals(e.getSQLState());
}
}

0 comments on commit 0c52c4b

Please sign in to comment.