3434import com .datastax .oss .driver .internal .core .config .typesafe .DefaultProgrammaticDriverConfigLoaderBuilder ;
3535import com .typesafe .config .Config ;
3636import com .typesafe .config .ConfigFactory ;
37+ import org .jspecify .annotations .Nullable ;
3738
3839import org .springframework .beans .factory .ObjectProvider ;
3940import org .springframework .beans .factory .config .ConfigurableBeanFactory ;
@@ -123,8 +124,9 @@ CqlSessionBuilder cassandraSessionBuilder(DriverConfigLoader driverConfigLoader,
123124
124125 private void configureAuthentication (CqlSessionBuilder builder , CassandraConnectionDetails connectionDetails ) {
125126 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 );
128130 }
129131 }
130132
@@ -260,7 +262,7 @@ private static final class CassandraDriverOptions {
260262
261263 private final Map <String , String > options = new LinkedHashMap <>();
262264
263- private CassandraDriverOptions add (DriverOption option , String value ) {
265+ private CassandraDriverOptions add (DriverOption option , @ Nullable String value ) {
264266 String key = createKeyFor (option );
265267 this .options .put (key , value );
266268 return this ;
@@ -298,9 +300,9 @@ static final class PropertiesCassandraConnectionDetails implements CassandraConn
298300
299301 private final CassandraProperties properties ;
300302
301- private final SslBundles sslBundles ;
303+ private final @ Nullable SslBundles sslBundles ;
302304
303- private PropertiesCassandraConnectionDetails (CassandraProperties properties , SslBundles sslBundles ) {
305+ private PropertiesCassandraConnectionDetails (CassandraProperties properties , @ Nullable SslBundles sslBundles ) {
304306 this .properties = properties ;
305307 this .sslBundles = sslBundles ;
306308 }
@@ -313,22 +315,22 @@ public List<Node> getContactPoints() {
313315 }
314316
315317 @ Override
316- public String getUsername () {
318+ public @ Nullable String getUsername () {
317319 return this .properties .getUsername ();
318320 }
319321
320322 @ Override
321- public String getPassword () {
323+ public @ Nullable String getPassword () {
322324 return this .properties .getPassword ();
323325 }
324326
325327 @ Override
326- public String getLocalDatacenter () {
328+ public @ Nullable String getLocalDatacenter () {
327329 return this .properties .getLocalDatacenter ();
328330 }
329331
330332 @ Override
331- public SslBundle getSslBundle () {
333+ public @ Nullable SslBundle getSslBundle () {
332334 Ssl ssl = this .properties .getSsl ();
333335 if (ssl == null || !ssl .isEnabled ()) {
334336 return null ;
@@ -352,7 +354,7 @@ private Node asNode(String contactPoint) {
352354 return new Node (contactPoint , this .properties .getPort ());
353355 }
354356
355- private Integer asPort (String value ) {
357+ private @ Nullable Integer asPort (String value ) {
356358 try {
357359 int i = Integer .parseInt (value );
358360 return (i > 0 && i < 65535 ) ? i : null ;
0 commit comments