From 26bb7728872d8d427857e0f0d17f9ad1d8d61ab9 Mon Sep 17 00:00:00 2001 From: Janick Reynders Date: Mon, 6 Mar 2023 18:38:08 +0100 Subject: [PATCH] Only call Messages.getString(...) when it's needed (when the SQLException is thrown) --- .../com/mysql/cj/jdbc/result/ResultSetImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java b/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java index 4a287878d..825fad86f 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java @@ -529,26 +529,26 @@ protected void checkRowPos() throws SQLException { checkClosed(); if (!this.onValidRow) { - throw SQLError.createSQLException(this.invalidRowReason, MysqlErrorNumbers.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); + throw SQLError.createSQLException(Messages.getString(this.invalidRowReasonMessageKey), MysqlErrorNumbers.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); } } private boolean onValidRow = false; - private String invalidRowReason = null; + private String invalidRowReasonMessageKey = null; - private void setRowPositionValidity() throws SQLException { + private void setRowPositionValidity() { if (!this.rowData.isDynamic() && (this.rowData.size() == 0)) { - this.invalidRowReason = Messages.getString("ResultSet.Illegal_operation_on_empty_result_set"); + this.invalidRowReasonMessageKey = "ResultSet.Illegal_operation_on_empty_result_set"; this.onValidRow = false; } else if (this.rowData.isBeforeFirst()) { - this.invalidRowReason = Messages.getString("ResultSet.Before_start_of_result_set_146"); + this.invalidRowReasonMessageKey = "ResultSet.Before_start_of_result_set_146"; this.onValidRow = false; } else if (this.rowData.isAfterLast()) { - this.invalidRowReason = Messages.getString("ResultSet.After_end_of_result_set_148"); + this.invalidRowReasonMessageKey = "ResultSet.After_end_of_result_set_148"; this.onValidRow = false; } else { this.onValidRow = true; - this.invalidRowReason = null; + this.invalidRowReasonMessageKey = null; } }