Skip to content

Commit

Permalink
Merge pull request #166 from scippacercola/main
Browse files Browse the repository at this point in the history
fix: logging of connection failures due to bad evaluation of a string…
  • Loading branch information
v1r3n authored Jul 1, 2024
2 parents 0c92193 + 0c52c4b commit 896a12e
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 896a12e

Please sign in to comment.