Skip to content

Commit

Permalink
Fix for Bug#108415 (Bug#34579258), NullPointerException in AbstractQu…
Browse files Browse the repository at this point in the history
…ery::stopQueryTimer.

Change-Id: I5a71825d70dd03dc0088ecaa71e743ac3e52ac8e
  • Loading branch information
fjssilva committed Sep 6, 2024
1 parent 5a27bc4 commit 1b317cf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

Version 9.1.0

- Fix for Bug#108415 (Bug#34579258), NullPointerException in AbstractQuery::stopQueryTimer.
Thanks to Anthony Milbourne for his contribution.

- Fix for Bug#115265 (Bug#36843227), Second stored procedure call with cacheCallableStmts might fail.

- Fix for Bug#36936407, PrepareCall method doesn't work as expected when DB name is involved.
Expand Down
4 changes: 3 additions & 1 deletion src/main/core-impl/java/com/mysql/cj/AbstractQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ public void stopQueryTimer(CancelQueryTask timeoutTask, boolean rethrowCancelRea
throw ExceptionFactory.createException(t.getMessage(), t);
}

this.session.getCancelTimer().purge();
if (this.session != null) {
this.session.getCancelTimer().purge();
}

if (checkCancelTimeout) {
checkCancelTimeout();
Expand Down
33 changes: 33 additions & 0 deletions src/test/java/testsuite/regression/StatementRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13796,4 +13796,37 @@ public void testBug112790() throws Exception {
assertThrows(SQLException.class, this.stmt::getGeneratedKeys);
}

/**
* Tests fix for Bug#108415 (Bug#34579258), NullPointerException in AbstractQuery::stopQueryTimer.
*
* @throws Exception
*/
@Test
void testBug108415() throws Exception {
Connection testConn = getNewConnection();
final long sessionToKill = ((JdbcConnection) testConn).getId();

ExecutorService execServ = Executors.newSingleThreadExecutor();
execServ.execute(() -> {
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
}
try {
System.out.println("Killing process id " + sessionToKill);
this.stmt.execute("KILL " + sessionToKill);
} catch (SQLException e) {
}
});

Statement testStmt = testConn.createStatement();
testStmt.setQueryTimeout(15);
assertThrows(SQLException.class, () -> {
testStmt.executeQuery("SELECT SLEEP(15)");
return null;
});

execServ.shutdown();
}

}

0 comments on commit 1b317cf

Please sign in to comment.