Skip to content

Commit

Permalink
Fix for Bug#22508715, SETSESSIONMAXROWS() CALL ON CLOSED CONNECTION
Browse files Browse the repository at this point in the history
RESULTS IN NPE.
  • Loading branch information
soklakov committed Feb 17, 2021
1 parent 3a8e187 commit 5be4e8c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Version 8.0.24

- Fix for Bug#22508715, SETSESSIONMAXROWS() CALL ON CLOSED CONNECTION RESULTS IN NPE.

- Fix for Bug#102131 (32338451), UPDATABLERESULTSET NPE WHEN USING DERIVED QUERIES OR VIEWS.

- Fix for Bug#101596 (32151143), GET THE 'HOST' PROPERTY ERROR AFTER CALLING TRANSFORMPROPERTIES() METHOD.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -2426,6 +2426,7 @@ public int getSessionMaxRows() {
@Override
public void setSessionMaxRows(int max) throws SQLException {
synchronized (getConnectionMutex()) {
checkClosed();
if (this.session.getSessionMaxRows() != max) {
this.session.setSessionMaxRows(max);
this.session.execSQL(null, "SET SQL_SELECT_LIMIT=" + (this.session.getSessionMaxRows() == -1 ? "DEFAULT" : this.session.getSessionMaxRows()),
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/testsuite/regression/ConnectionRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11796,4 +11796,21 @@ public Properties transformProperties(Properties props) {
return props;
}
}

/**
* Tests fix for Bug#22508715, SETSESSIONMAXROWS() CALL ON CLOSED CONNECTION RESULTS IN NPE.
*
* @throws Exception
*/
@Test
public void testBug22508715() throws Exception {
Properties props = new Properties();
Connection con = getConnectionWithProps(props);
con.close();

assertThrows(SQLNonTransientConnectionException.class, "No operations allowed after connection closed.*", () -> {
((JdbcConnection) con).setSessionMaxRows(0);
return null;
});
}
}

0 comments on commit 5be4e8c

Please sign in to comment.