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 24
24
import com .datastax .oss .driver .api .core .tracker .RequestTracker ;
25
25
import edu .umd .cs .findbugs .annotations .NonNull ;
26
26
import edu .umd .cs .findbugs .annotations .Nullable ;
27
+ import java .util .Collections ;
27
28
import java .util .Map ;
28
29
import java .util .Optional ;
29
30
import java .util .Queue ;
@@ -78,8 +79,8 @@ default Optional<RequestTracker> getRequestTracker() {
78
79
79
80
/** Returns map containing details that impact C* node connectivity. */
80
81
@ NonNull
81
- default Optional < Map <String , ?> > getStartupConfiguration () {
82
- return Optional . empty ();
82
+ default Map <String , ?> getStartupConfiguration () {
83
+ return Collections . emptyMap ();
83
84
}
84
85
85
86
/**
Original file line number Diff line number Diff line change @@ -159,10 +159,10 @@ private Optional<String> driverBaggage() {
159
159
ImmutableMap .Builder <String , Object > builder = new ImmutableMap .Builder <>();
160
160
for (Map .Entry <String , LoadBalancingPolicy > entry :
161
161
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
+ }
166
166
}
167
167
try {
168
168
return Optional .of (mapper .writeValueAsString (builder .build ()));
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ public String getLocalDatacenter() {
162
162
163
163
@ NonNull
164
164
@ Override
165
- public Optional < Map <String , ?> > getStartupConfiguration () {
165
+ public Map <String , ?> getStartupConfiguration () {
166
166
ImmutableMap .Builder <String , Object > builder = new ImmutableMap .Builder <>();
167
167
if (localDc != null ) {
168
168
builder .put ("localDc" , localDc );
@@ -185,8 +185,7 @@ public String getLocalDatacenter() {
185
185
if (maxNodesPerRemoteDc > 0 ) {
186
186
builder .put ("maxNodesPerRemoteDc" , maxNodesPerRemoteDc );
187
187
}
188
- return Optional .of (
189
- ImmutableMap .of (BasicLoadBalancingPolicy .class .getSimpleName (), builder .build ()));
188
+ return ImmutableMap .of (BasicLoadBalancingPolicy .class .getSimpleName (), builder .build ());
190
189
}
191
190
192
191
/** @return The nodes currently considered as live. */
Original file line number Diff line number Diff line change 39
39
import edu .umd .cs .findbugs .annotations .NonNull ;
40
40
import edu .umd .cs .findbugs .annotations .Nullable ;
41
41
import java .util .BitSet ;
42
- import java .util .Collections ;
43
42
import java .util .Map ;
44
43
import java .util .Optional ;
45
44
import java .util .OptionalLong ;
@@ -355,11 +354,10 @@ private boolean hasSufficientResponses(long now) {
355
354
356
355
@ NonNull
357
356
@ 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 ()));
364
362
}
365
363
}
You can’t perform that action at this time.
0 commit comments