Skip to content

Commit 0f04ce6

Browse files
jesperahjesperah
and
jesperah
authored
missing null check of e.getCause(). (#2300)
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>
1 parent a6004e9 commit 0f04ce6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@ final void executeStatement(TDSCommand newStmtCmd) throws SQLServerException, SQ
262262
// (Re)execute this Statement with the new command
263263
executeCommand(newStmtCmd);
264264
} catch (SQLServerException e) {
265-
if (e.getDriverErrorCode() == SQLServerException.ERROR_QUERY_TIMEOUT)
265+
if (e.getDriverErrorCode() == SQLServerException.ERROR_QUERY_TIMEOUT) {
266+
if (e.getCause() == null) {
267+
throw new SQLTimeoutException(e.getMessage(), e.getSQLState(), e.getErrorCode(), e);
268+
}
266269
throw new SQLTimeoutException(e.getMessage(), e.getSQLState(), e.getErrorCode(), e.getCause());
267-
else
270+
} else {
268271
throw e;
272+
}
269273
} finally {
270274
if (newStmtCmd.wasExecuted())
271275
lastStmtExecCmd = newStmtCmd;

0 commit comments

Comments
 (0)