Skip to content

Commit de7e1af

Browse files
committed
Fix for Bug#30636056, ResultSetUtil.resultSetToMap() can be unsafe to use.
1 parent 2f5bcbb commit de7e1af

File tree

3 files changed

+10
-99
lines changed

3 files changed

+10
-99
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 8.0.20
55

6+
- Fix for Bug#30636056, ResultSetUtil.resultSetToMap() can be unsafe to use.
7+
68
- Fix for Bug#97757 (30584907), NULLPOINTEREXCEPTION WITH CACHERESULTSETMETADATA=TRUE AND EXECUTEQUERY OF "SET".
79

810
Version 8.0.19

src/main/user-impl/java/com/mysql/cj/jdbc/interceptors/ServerStatusDiffInterceptor.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -29,7 +29,9 @@
2929

3030
package com.mysql.cj.jdbc.interceptors;
3131

32+
import java.sql.ResultSet;
3233
import java.sql.SQLException;
34+
import java.sql.Statement;
3335
import java.util.HashMap;
3436
import java.util.Map;
3537
import java.util.Properties;
@@ -40,7 +42,6 @@
4042
import com.mysql.cj.exceptions.ExceptionFactory;
4143
import com.mysql.cj.interceptors.QueryInterceptor;
4244
import com.mysql.cj.jdbc.JdbcConnection;
43-
import com.mysql.cj.jdbc.util.ResultSetUtil;
4445
import com.mysql.cj.log.Log;
4546
import com.mysql.cj.protocol.Resultset;
4647
import com.mysql.cj.protocol.ServerSession;
@@ -75,23 +76,14 @@ public <T extends Resultset> T postProcess(Supplier<String> sql, Query intercept
7576
}
7677

7778
private void populateMapWithSessionStatusValues(Map<String, String> toPopulate) {
78-
java.sql.Statement stmt = null;
79-
java.sql.ResultSet rs = null;
80-
8179
try {
82-
try {
80+
try (Statement stmt = this.connection.createStatement()) {
8381
toPopulate.clear();
8482

85-
stmt = this.connection.createStatement();
86-
rs = stmt.executeQuery("SHOW SESSION STATUS");
87-
ResultSetUtil.resultSetToMap(toPopulate, rs);
88-
} finally {
89-
if (rs != null) {
90-
rs.close();
91-
}
92-
93-
if (stmt != null) {
94-
stmt.close();
83+
try (ResultSet rs = stmt.executeQuery("SHOW SESSION STATUS")) {
84+
while (rs.next()) {
85+
toPopulate.put(rs.getString(1), rs.getString(2));
86+
}
9587
}
9688
}
9789
} catch (SQLException ex) {

src/main/user-impl/java/com/mysql/cj/jdbc/util/ResultSetUtil.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)