File tree Expand file tree Collapse file tree 4 files changed +14
-16
lines changed
core/src/main/java/com/datastax/oss/driver Expand file tree Collapse file tree 4 files changed +14
-16
lines changed Original file line number Diff line number Diff line change 2424import com .datastax .oss .driver .api .core .tracker .RequestTracker ;
2525import edu .umd .cs .findbugs .annotations .NonNull ;
2626import edu .umd .cs .findbugs .annotations .Nullable ;
27+ import java .util .Collections ;
2728import java .util .Map ;
2829import java .util .Optional ;
2930import java .util .Queue ;
@@ -78,8 +79,8 @@ default Optional<RequestTracker> getRequestTracker() {
7879
7980 /** Returns map containing details that impact C* node connectivity. */
8081 @ NonNull
81- default Optional < Map <String , ?> > getStartupConfiguration () {
82- return Optional . empty ();
82+ default Map <String , ?> getStartupConfiguration () {
83+ return Collections . emptyMap ();
8384 }
8485
8586 /**
Original file line number Diff line number Diff line change @@ -159,10 +159,10 @@ private Optional<String> driverBaggage() {
159159 ImmutableMap .Builder <String , Object > builder = new ImmutableMap .Builder <>();
160160 for (Map .Entry <String , LoadBalancingPolicy > entry :
161161 context .getLoadBalancingPolicies ().entrySet ()) {
162- entry
163- . getValue ()
164- . getStartupConfiguration ()
165- . ifPresent ( baggage -> builder . put ( entry . getKey (), baggage ));
162+ Map < String , ?> config = entry . getValue (). getStartupConfiguration ();
163+ if (! config . isEmpty ()) {
164+ builder . put ( entry . getKey (), config );
165+ }
166166 }
167167 try {
168168 return Optional .of (mapper .writeValueAsString (builder .build ()));
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ public String getLocalDatacenter() {
162162
163163 @ NonNull
164164 @ Override
165- public Optional < Map <String , ?> > getStartupConfiguration () {
165+ public Map <String , ?> getStartupConfiguration () {
166166 ImmutableMap .Builder <String , Object > builder = new ImmutableMap .Builder <>();
167167 if (localDc != null ) {
168168 builder .put ("localDc" , localDc );
@@ -185,8 +185,7 @@ public String getLocalDatacenter() {
185185 if (maxNodesPerRemoteDc > 0 ) {
186186 builder .put ("maxNodesPerRemoteDc" , maxNodesPerRemoteDc );
187187 }
188- return Optional .of (
189- ImmutableMap .of (BasicLoadBalancingPolicy .class .getSimpleName (), builder .build ()));
188+ return ImmutableMap .of (BasicLoadBalancingPolicy .class .getSimpleName (), builder .build ());
190189 }
191190
192191 /** @return The nodes currently considered as live. */
Original file line number Diff line number Diff line change 3939import edu .umd .cs .findbugs .annotations .NonNull ;
4040import edu .umd .cs .findbugs .annotations .Nullable ;
4141import java .util .BitSet ;
42- import java .util .Collections ;
4342import java .util .Map ;
4443import java .util .Optional ;
4544import java .util .OptionalLong ;
@@ -355,11 +354,10 @@ private boolean hasSufficientResponses(long now) {
355354
356355 @ NonNull
357356 @ Override
358- public Optional <Map <String , ?>> getStartupConfiguration () {
359- Map <String , ?> parent = super .getStartupConfiguration ().orElse (Collections .emptyMap ());
360- return Optional .of (
361- ImmutableMap .of (
362- DefaultLoadBalancingPolicy .class .getSimpleName (),
363- parent .get (BasicLoadBalancingPolicy .class .getSimpleName ())));
357+ public Map <String , ?> getStartupConfiguration () {
358+ Map <String , ?> parent = super .getStartupConfiguration ();
359+ return ImmutableMap .of (
360+ DefaultLoadBalancingPolicy .class .getSimpleName (),
361+ parent .get (BasicLoadBalancingPolicy .class .getSimpleName ()));
364362 }
365363}
You can’t perform that action at this time.
0 commit comments