34
34
import com .datastax .oss .driver .internal .core .config .typesafe .DefaultProgrammaticDriverConfigLoaderBuilder ;
35
35
import com .typesafe .config .Config ;
36
36
import com .typesafe .config .ConfigFactory ;
37
+ import org .jspecify .annotations .Nullable ;
37
38
38
39
import org .springframework .beans .factory .ObjectProvider ;
39
40
import org .springframework .beans .factory .config .ConfigurableBeanFactory ;
@@ -123,8 +124,9 @@ CqlSessionBuilder cassandraSessionBuilder(DriverConfigLoader driverConfigLoader,
123
124
124
125
private void configureAuthentication (CqlSessionBuilder builder , CassandraConnectionDetails connectionDetails ) {
125
126
String username = connectionDetails .getUsername ();
126
- if (username != null ) {
127
- builder .withAuthCredentials (username , connectionDetails .getPassword ());
127
+ String password = connectionDetails .getPassword ();
128
+ if (username != null && password != null ) {
129
+ builder .withAuthCredentials (username , password );
128
130
}
129
131
}
130
132
@@ -260,7 +262,7 @@ private static final class CassandraDriverOptions {
260
262
261
263
private final Map <String , String > options = new LinkedHashMap <>();
262
264
263
- private CassandraDriverOptions add (DriverOption option , String value ) {
265
+ private CassandraDriverOptions add (DriverOption option , @ Nullable String value ) {
264
266
String key = createKeyFor (option );
265
267
this .options .put (key , value );
266
268
return this ;
@@ -298,9 +300,9 @@ static final class PropertiesCassandraConnectionDetails implements CassandraConn
298
300
299
301
private final CassandraProperties properties ;
300
302
301
- private final SslBundles sslBundles ;
303
+ private final @ Nullable SslBundles sslBundles ;
302
304
303
- private PropertiesCassandraConnectionDetails (CassandraProperties properties , SslBundles sslBundles ) {
305
+ private PropertiesCassandraConnectionDetails (CassandraProperties properties , @ Nullable SslBundles sslBundles ) {
304
306
this .properties = properties ;
305
307
this .sslBundles = sslBundles ;
306
308
}
@@ -313,22 +315,22 @@ public List<Node> getContactPoints() {
313
315
}
314
316
315
317
@ Override
316
- public String getUsername () {
318
+ public @ Nullable String getUsername () {
317
319
return this .properties .getUsername ();
318
320
}
319
321
320
322
@ Override
321
- public String getPassword () {
323
+ public @ Nullable String getPassword () {
322
324
return this .properties .getPassword ();
323
325
}
324
326
325
327
@ Override
326
- public String getLocalDatacenter () {
328
+ public @ Nullable String getLocalDatacenter () {
327
329
return this .properties .getLocalDatacenter ();
328
330
}
329
331
330
332
@ Override
331
- public SslBundle getSslBundle () {
333
+ public @ Nullable SslBundle getSslBundle () {
332
334
Ssl ssl = this .properties .getSsl ();
333
335
if (ssl == null || !ssl .isEnabled ()) {
334
336
return null ;
@@ -352,7 +354,7 @@ private Node asNode(String contactPoint) {
352
354
return new Node (contactPoint , this .properties .getPort ());
353
355
}
354
356
355
- private Integer asPort (String value ) {
357
+ private @ Nullable Integer asPort (String value ) {
356
358
try {
357
359
int i = Integer .parseInt (value );
358
360
return (i > 0 && i < 65535 ) ? i : null ;
0 commit comments