Skip to content
Prev Previous commit
Next Next commit
Fix Google Java Format violations in createSSLContextFromKeystore method
- Break long exception messages across multiple lines
- Fix line length violations for static analysis compliance
- Maintain consistent formatting with existing codebase

Co-Authored-By: [email protected] <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and nbagnard committed Sep 19, 2025
commit 039e0ada54a7897a207d8d0304d08d760e699ec5
19 changes: 14 additions & 5 deletions src/main/java/com/mongodb/jdbc/utils/X509Authentication.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public void configureX509AuthenticationFromKeystore(
logger.log(Level.FINE, "Certificate alias: " + certificateAlias);

try {
SSLContext sslContext = createSSLContextFromKeystore(keystorePath, keystorePassword, certificateAlias);
SSLContext sslContext =
createSSLContextFromKeystore(keystorePath, keystorePassword, certificateAlias);

settingsBuilder.applyToSslSettings(
sslSettings -> {
Expand Down Expand Up @@ -445,23 +446,31 @@ private SSLContext createSSLContextFromKeystore(

Certificate cert = keystore.getCertificate(certificateAlias);
if (cert == null) {
throw new MongoException("Certificate with alias '" + certificateAlias + "' not found in keystore");
throw new MongoException(
"Certificate with alias '" + certificateAlias + "' not found in keystore");
}
logger.log(Level.FINE, "Found certificate with alias: " + certificateAlias);

PrivateKey privateKey;
try {
Key key = keystore.getKey(certificateAlias, keystorePassword);
if (key == null) {
throw new MongoException("Private key with alias '" + certificateAlias + "' not found in keystore");
throw new MongoException(
"Private key with alias '" + certificateAlias + "' not found in keystore");
}
if (!(key instanceof PrivateKey)) {
throw new MongoException("Key with alias '" + certificateAlias + "' is not a private key");
}
privateKey = (PrivateKey) key;
logger.log(Level.FINE, "Successfully extracted private key with alias: " + certificateAlias);
logger.log(
Level.FINE, "Successfully extracted private key with alias: " + certificateAlias);
} catch (UnrecoverableKeyException e) {
throw new MongoException("Failed to extract private key with alias '" + certificateAlias + "': " + e.getMessage(), e);
throw new MongoException(
"Failed to extract private key with alias '"
+ certificateAlias
+ "': "
+ e.getMessage(),
e);
}

return createSSLContextFromKeyAndCert(privateKey, cert);
Expand Down