Skip to content

Commit

Permalink
missing null check of e.getCause(). (#2300)
Browse files Browse the repository at this point in the history
if the caught exception does not have a cause then pass the caught exception as the cause to the SQLTimeoutException instead of the null "e.getCause()". (#2299)

Co-authored-by: jesperah <jesperah@rob-ex.com>
  • Loading branch information
jesperah and jesperah committed Jan 15, 2024
1 parent a6004e9 commit 0f04ce6
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@ final void executeStatement(TDSCommand newStmtCmd) throws SQLServerException, SQ
// (Re)execute this Statement with the new command
executeCommand(newStmtCmd);
} catch (SQLServerException e) {
if (e.getDriverErrorCode() == SQLServerException.ERROR_QUERY_TIMEOUT)
if (e.getDriverErrorCode() == SQLServerException.ERROR_QUERY_TIMEOUT) {
if (e.getCause() == null) {
throw new SQLTimeoutException(e.getMessage(), e.getSQLState(), e.getErrorCode(), e);
}
throw new SQLTimeoutException(e.getMessage(), e.getSQLState(), e.getErrorCode(), e.getCause());
else
} else {
throw e;
}
} finally {
if (newStmtCmd.wasExecuted())
lastStmtExecCmd = newStmtCmd;
Expand Down

0 comments on commit 0f04ce6

Please sign in to comment.