Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with truststore password being removed too early for XA transaction #1133

Merged
merged 16 commits into from
Sep 27, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ public void setTrustStorePassword(String trustStorePassword) {
trustStorePassword);
}

String getTrustStorePassword() {
return getStringProperty(connectionProps, SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString(), null);
}

@Override
public void setHostNameInCertificate(String hostName) {
setStringProperty(connectionProps, SQLServerDriverStringProperty.HOSTNAME_IN_CERTIFICATE.toString(), hostName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ public final class SQLServerXAConnection extends SQLServerPooledConnection imple
controlConnectionProperties.setProperty(SQLServerDriverStringProperty.PASSWORD.toString(), pwd);
}

// Add truststore password property for creating the control connection. This will be removed again
ulvii marked this conversation as resolved.
Show resolved Hide resolved
String trustStorePassword = ds.getTrustStorePassword();
if (null == trustStorePassword) {
// trustStorePassword can either come from the connection string or added via SQLServerXADataSource::setTrustStorePassword.
// if trustStorePassword is null at this point, then check the connection string.
Properties urlProps = Util.parseUrl(ds.getURL(), xaLogger);
trustStorePassword = urlProps.getProperty(SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString());
}

// if trustStorePassword is still null, it wasn't provided. Do not set the property as null to avoid NPE.
if (null != trustStorePassword) {
peterbae marked this conversation as resolved.
Show resolved Hide resolved
controlConnectionProperties.setProperty(SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString(), trustStorePassword);
}

if (xaLogger.isLoggable(Level.FINER))
xaLogger.finer("Creating an internal control connection for" + toString());
physicalControlConnection = null;
Expand Down