From f8b061ff4bbe7897a8e87402009c321d8dd63096 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 29 Jun 2018 17:06:27 -0700 Subject: [PATCH] Fix Conflict issues with master branch --- .../sqlserver/jdbc/SQLServerConnection.java | 25 +++---------------- .../jdbc/SQLServerPreparedStatement.java | 3 ++- .../ISQLServerBulkRecordIssuesTest.java | 2 ++ .../statement/BatchExecuteWithErrorsTest.java | 2 ++ .../unit/statement/PreparedStatementTest.java | 1 - 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index b2111c923..0c4b2bef9 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -117,8 +117,6 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial private byte[] accessTokenInByte = null; private SqlFedAuthToken fedAuthToken = null; - - private String originalHostNameInCertificate = null; private String originalHostNameInCertificate = null; @@ -410,7 +408,7 @@ private enum State { ServerPortPlaceHolder getRoutingInfo() { return routingInfo; } - + // Permission targets private static final String callAbortPerm = "callAbort"; @@ -1206,23 +1204,6 @@ Connection connectInternal(Properties propsIn, activeConnectionProperties = (Properties) propsIn.clone(); pooledConnectionParent = pooledConnection; - - String hostNameInCertificate = activeConnectionProperties. - getProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString()); - - // hostNameInCertificate property can change when redirection is involved, so maintain this value - // for every instance of SQLServerConnection. - if (null == originalHostNameInCertificate && null != hostNameInCertificate && !hostNameInCertificate.isEmpty()) { - originalHostNameInCertificate = activeConnectionProperties. - getProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString()); - } - - if (null != originalHostNameInCertificate && !originalHostNameInCertificate.isEmpty()) { - // if hostNameInCertificate has a legitimate value (and not empty or null), - // reset hostNameInCertificate to the original value every time we connect (or re-connect). - activeConnectionProperties.setProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), - originalHostNameInCertificate); - } String hostNameInCertificate = activeConnectionProperties.getProperty(SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString()); @@ -3519,7 +3500,8 @@ private void logon(LogonCommand command) throws SQLServerException { connectionCommand(sqlStmt, "Change Settings"); } } - } finally { + } + finally { if (integratedSecurity) { if (null != authentication) { authentication.ReleaseClientContext(); @@ -3741,6 +3723,7 @@ final void processEnvChange(TDSReader tdsReader) throws SQLServerException { isRoutedInCurrentAttempt = true; routingInfo = new ServerPortPlaceHolder(routingServerName, routingPortNumber, null, integratedSecurity); + break; // Error on unrecognized, unused ENVCHANGES diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index cf4578fe5..063dabe39 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -166,7 +166,7 @@ private boolean resetPrepStmtHandle(boolean discardCurrentCacheItem) { prepStmtHandle = 0; return statementPoolingUsed; } - + /** Flag set to true when statement execution is expected to return the prepared statement handle */ private boolean expectPrepStmtHandle = false; @@ -252,6 +252,7 @@ private void closePreparedHandle() { else { isExecutedAtLeastOnce = false; final int handleToClose = prepStmtHandle; + // Handle unprepare actions through statement pooling. if (resetPrepStmtHandle(false)) { connection.returnCachedPreparedStatementHandle(cachedPreparedStatementHandle); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/ISQLServerBulkRecordIssuesTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/ISQLServerBulkRecordIssuesTest.java index 38ae1b4d0..bb24c65dc 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/ISQLServerBulkRecordIssuesTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/ISQLServerBulkRecordIssuesTest.java @@ -42,6 +42,7 @@ @RunWith(JUnitPlatform.class) public class ISQLServerBulkRecordIssuesTest extends AbstractTest { + static Statement stmt = null; static PreparedStatement pStmt = null; static String query; @@ -271,6 +272,7 @@ public static void afterAllTests() throws SQLException { con.close(); } } + } class BulkData implements ISQLServerBulkRecord { diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecuteWithErrorsTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecuteWithErrorsTest.java index 550369b4c..e3659adfc 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecuteWithErrorsTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecuteWithErrorsTest.java @@ -297,10 +297,12 @@ private void Repro47239Internal(String mode) throws Exception { catch (Exception ignored) { } } + } } private void Repro47239largeInternal(String mode) throws Exception { + assumeTrue("JDBC42".equals(Utils.getConfiguredProperty("JDBC_Version")), TestResource.getResource("R_incompatJDBC")); // the DBConnection for detecting whether the server is SQL Azure or SQL Server. con = DriverManager.getConnection(connectionString); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/PreparedStatementTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/PreparedStatementTest.java index 96cb920ac..78b2777b0 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/PreparedStatementTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/PreparedStatementTest.java @@ -136,7 +136,6 @@ public void testBatchedUnprepare() throws SQLException { @Tag("slow") public void testStatementPooling() throws Exception { testStatementPoolingInternal("batchInsert"); - } /**