Skip to content

Commit 4ea1794

Browse files
committed
Added a reference to enclave retry to variables added in SQLServerConnection, for better clarity.
1 parent 5ee6c28 commit 4ea1794

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,9 @@ boolean getServerSupportsColumnEncryption() {
855855
ColumnEncryptionVersion getServerColumnEncryptionVersion() {
856856
return serverColumnEncryptionVersion;
857857
}
858-
859-
/** whether the server supports retrying a connection on failure */
860-
private boolean serverSupportsRetry = false;
858+
859+
/** whether the server supports retrying an invalid enclave connection */
860+
private boolean serverSupportsEnclaveRetry = false;
861861

862862
/** whether server supports data classification */
863863
private boolean serverSupportsDataClassification = false;
@@ -5711,11 +5711,11 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept
57115711
if (aeVersion < TDS.COLUMNENCRYPTION_VERSION2) {
57125712
throw new SQLServerException(SQLServerException.getErrString("R_enclaveNotSupported"), null);
57135713
} else {
5714-
serverColumnEncryptionVersion = aeVersion == TDS.COLUMNENCRYPTION_VERSION3
5715-
? ColumnEncryptionVersion.AE_V3 : ColumnEncryptionVersion.AE_V2;
5714+
serverColumnEncryptionVersion = aeVersion == TDS.COLUMNENCRYPTION_VERSION3 ? ColumnEncryptionVersion.AE_V3
5715+
: ColumnEncryptionVersion.AE_V2;
57165716
enclaveType = new String(data, 2, data.length - 2, UTF_16LE);
57175717
}
5718-
serverSupportsRetry = aeVersion == TDS.COLUMNENCRYPTION_VERSION3;
5718+
serverSupportsEnclaveRetry = aeVersion == TDS.COLUMNENCRYPTION_VERSION3;
57195719

57205720
if (!EnclaveType.isValidEnclaveType(enclaveType)) {
57215721
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_enclaveTypeInvalid"));
@@ -7678,9 +7678,9 @@ final synchronized void removeOpenStatement(ISQLServerStatement st) {
76787678
boolean isAEv2() {
76797679
return (aeVersion >= TDS.COLUMNENCRYPTION_VERSION2);
76807680
}
7681-
7682-
boolean isRetrySupported() {
7683-
return serverSupportsRetry;
7681+
7682+
boolean doesServerSupportEnclaveRetry() {
7683+
return serverSupportsEnclaveRetry;
76847684
}
76857685

76867686
/** Enclave provider */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ final void doExecutePreparedStatement(PrepStmtExecCmd command) throws SQLServerE
621621
} catch (SQLException e) {
622622
if (retryBasedOnFailedReuseOfCachedHandle(e, attempt, needsPrepare, false)) {
623623
continue;
624-
} else if (!inRetry && connection.isRetrySupported()) {
624+
} else if (!inRetry && connection.doesServerSupportEnclaveRetry()) {
625625
// We only want to retry once, so no retrying if we're already in the second pass.
626626
// If we are AE_v3, remove the failed entry and try again.
627627
ParameterMetaDataCache.removeCacheEntry(this, connection, preparedSQL);

src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/ParameterMetaDataCacheTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void testRetryWithSecureCache() throws Exception {
135135
TestUtils.dropTableIfExists(CHAR_TABLE_AE, stmt);
136136
createTable(CHAR_TABLE_AE, cekAkv, charTable);
137137
populateCharNormalCase(values);
138-
if (TestUtils.isRetrySupported(con)) {
138+
if (TestUtils.doesServerSupportEnclaveRetry(con)) {
139139
testAlterColumnEncryption((SQLServerStatement) stmt, CHAR_TABLE_AE, charTable, cekAkv);
140140
}
141141
populateCharNormalCase(values);

src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.List;
3030
import java.util.Locale;
3131
import java.util.ResourceBundle;
32+
3233
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
3334
import com.microsoft.sqlserver.testframework.PrepUtil;
3435
import com.microsoft.sqlserver.testframework.sqlType.SqlBigInt;
@@ -134,14 +135,14 @@ public static boolean isAzureMI(Connection con) {
134135
public static boolean isAEv2(Connection con) {
135136
return ((SQLServerConnection) con).isAEv2();
136137
}
137-
138+
138139
/**
139-
* Returns whether the server supports retrying a connection on failure
140-
*
141-
* @see com.microsoft.sqlserver.jdbc.SQLServerConnection#isRetrySupported()
142-
*/
143-
public static boolean isRetrySupported(Connection con) {
144-
return ((SQLServerConnection) con).isRetrySupported();
140+
* Returns whether the server supports retrying a connection on failure
141+
*
142+
* @see com.microsoft.sqlserver.jdbc.SQLServerConnection#doesServerSupportEnclaveRetry()
143+
*/
144+
public static boolean doesServerSupportEnclaveRetry(Connection con) {
145+
return ((SQLServerConnection) con).doesServerSupportEnclaveRetry();
145146
}
146147

147148
/**

0 commit comments

Comments
 (0)