@@ -276,11 +276,12 @@ private MethodSpec finalizeServiceConfigurationMethod() {
276
276
builder .addCode ("return config.toBuilder()\n " );
277
277
278
278
if (model .getCustomizationConfig ().getServiceConfig ().hasDualstackProperty ()) {
279
- builder .addCode (".option($T.DUALSTACK_ENDPOINT_ENABLED, c.dualstackEnabled())" , AwsClientOption .class );
279
+ builder .addCode (".option($T.DUALSTACK_ENDPOINT_ENABLED, finalServiceConfig.dualstackEnabled())" ,
280
+ AwsClientOption .class );
280
281
}
281
282
282
283
if (model .getCustomizationConfig ().getServiceConfig ().hasFipsProperty ()) {
283
- builder .addCode (".option($T.FIPS_ENDPOINT_ENABLED, c .fipsModeEnabled())" , AwsClientOption .class );
284
+ builder .addCode (".option($T.FIPS_ENDPOINT_ENABLED, finalServiceConfig .fipsModeEnabled())" , AwsClientOption .class );
284
285
}
285
286
286
287
if (model .getEndpointOperation ().isPresent ()) {
@@ -297,7 +298,7 @@ private MethodSpec finalizeServiceConfigurationMethod() {
297
298
}
298
299
299
300
if (StringUtils .isNotBlank (clientConfigClassName )) {
300
- builder .addCode (".option($T.SERVICE_CONFIGURATION, c.build() )" , SdkClientOption .class );
301
+ builder .addCode (".option($T.SERVICE_CONFIGURATION, finalServiceConfig )" , SdkClientOption .class );
301
302
}
302
303
303
304
if (model .getCustomizationConfig ().useGlobalEndpoint ()) {
@@ -315,65 +316,71 @@ private MethodSpec finalizeServiceConfigurationMethod() {
315
316
316
317
private void mergeServiceConfiguration (MethodSpec .Builder builder , String clientConfigClassName ) {
317
318
ClassName clientConfigClass = ClassName .bestGuess (clientConfigClassName );
318
- builder .addCode ("$1T.Builder c = (($1T) config.option($2T.SERVICE_CONFIGURATION)).toBuilder();" +
319
- "c.profileFile(c.profileFile() != null ? c.profileFile() : config.option($2T.PROFILE_FILE));" +
320
- "c.profileName(c.profileName() != null ? c.profileName() : config.option($2T.PROFILE_NAME));" ,
319
+ builder .addCode ("$1T.Builder serviceConfigBuilder = (($1T) config.option($2T.SERVICE_CONFIGURATION)).toBuilder();" +
320
+ "serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFile() "
321
+ + "!= null ? serviceConfigBuilder.profileFile() : config.option($2T.PROFILE_FILE));" +
322
+ "serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() "
323
+ + "!= null ? serviceConfigBuilder.profileName() : config.option($2T.PROFILE_NAME));" ,
321
324
clientConfigClass , SdkClientOption .class );
322
325
326
+
327
+
323
328
if (model .getCustomizationConfig ().getServiceConfig ().hasDualstackProperty ()) {
324
- builder .addCode ("if (c .dualstackEnabled() != null) {" )
329
+ builder .addCode ("if (serviceConfigBuilder .dualstackEnabled() != null) {" )
325
330
.addCode (" $T.validState(config.option($T.DUALSTACK_ENDPOINT_ENABLED) == null, \" Dualstack has been "
326
331
+ "configured on both $L and the client/global level. Please limit dualstack configuration to "
327
332
+ "one location.\" );" ,
328
333
Validate .class , AwsClientOption .class , clientConfigClassName )
329
334
.addCode ("} else {" )
330
- .addCode (" c.dualstackEnabled(config.option($T.DUALSTACK_ENDPOINT_ENABLED));" , AwsClientOption .class )
335
+ .addCode (" serviceConfigBuilder.dualstackEnabled(config.option($T.DUALSTACK_ENDPOINT_ENABLED));" ,
336
+ AwsClientOption .class )
331
337
.addCode ("}" );
332
338
}
333
339
334
340
if (model .getCustomizationConfig ().getServiceConfig ().hasFipsProperty ()) {
335
- builder .addCode ("if (c .fipsModeEnabled() != null) {" )
341
+ builder .addCode ("if (serviceConfigBuilder .fipsModeEnabled() != null) {" )
336
342
.addCode (" $T.validState(config.option($T.FIPS_ENDPOINT_ENABLED) == null, \" Fips has been "
337
343
+ "configured on both $L and the client/global level. Please limit fips configuration to "
338
344
+ "one location.\" );" ,
339
345
Validate .class , AwsClientOption .class , clientConfigClassName )
340
346
.addCode ("} else {" )
341
- .addCode (" c.fipsModeEnabled(config.option($T.FIPS_ENDPOINT_ENABLED));" , AwsClientOption .class )
347
+ .addCode (" serviceConfigBuilder.fipsModeEnabled(config.option($T.FIPS_ENDPOINT_ENABLED));" ,
348
+ AwsClientOption .class )
342
349
.addCode ("}" );
343
350
}
344
351
352
+ builder .addStatement ("$T finalServiceConfig = serviceConfigBuilder.build()" , clientConfigClass );
353
+
345
354
if (model .getCustomizationConfig ().getServiceConfig ().hasUseArnRegionProperty ()) {
346
- builder .addCode (CodeBlock . builder (). beginControlFlow ( "if (c.useArnRegionEnabled() != null)" )
347
- . addStatement ( "clientContextParams.put($T.USE_ARN_REGION, c.useArnRegionEnabled())" ,
348
- endpointRulesSpecUtils . clientContextParamsName ())
349
- . endControlFlow ( )
350
- .build ());
355
+ builder .addCode (
356
+ CodeBlock . builder ()
357
+ . addStatement ( "clientContextParams.put($T.USE_ARN_REGION, finalServiceConfig.useArnRegionEnabled ())" ,
358
+ endpointRulesSpecUtils . clientContextParamsName () )
359
+ .build ());
351
360
}
352
361
353
362
if (model .getCustomizationConfig ().getServiceConfig ().hasMultiRegionEnabledProperty ()) {
354
- builder .addCode (CodeBlock . builder (). beginControlFlow ( "if (c.multiRegionEnabled() != null)" )
355
- . addStatement ( "clientContextParams.put($T.DISABLE_MULTI_REGION_ACCESS_POINTS, !c"
356
- + ".multiRegionEnabled())" ,
357
- endpointRulesSpecUtils . clientContextParamsName ())
358
- . endControlFlow ( )
359
- .build ());
363
+ builder .addCode (
364
+ CodeBlock . builder ()
365
+ . addStatement ( "clientContextParams.put($T.DISABLE_MULTI_REGION_ACCESS_POINTS, !finalServiceConfig"
366
+ + ".multiRegionEnabled ())" ,
367
+ endpointRulesSpecUtils . clientContextParamsName () )
368
+ .build ());
360
369
}
361
370
362
371
if (model .getCustomizationConfig ().getServiceConfig ().hasForcePathTypeEnabledProperty ()) {
363
- builder .addCode (CodeBlock .builder (). beginControlFlow ( "if (c.pathStyleAccessEnabled() != null)" )
364
- .addStatement ("clientContextParams.put($T.FORCE_PATH_STYLE, c "
372
+ builder .addCode (CodeBlock .builder ()
373
+ .addStatement ("clientContextParams.put($T.FORCE_PATH_STYLE, finalServiceConfig "
365
374
+ ".pathStyleAccessEnabled())" ,
366
375
endpointRulesSpecUtils .clientContextParamsName ())
367
- .endControlFlow ()
368
376
.build ());
369
377
}
370
378
371
379
if (model .getCustomizationConfig ().getServiceConfig ().hasAccelerateModeEnabledProperty ()) {
372
- builder .addCode (CodeBlock .builder (). beginControlFlow ( "if (c.accelerateModeEnabled() != null)" )
373
- .addStatement ("clientContextParams.put($T.ACCELERATE, c "
380
+ builder .addCode (CodeBlock .builder ()
381
+ .addStatement ("clientContextParams.put($T.ACCELERATE, finalServiceConfig "
374
382
+ ".accelerateModeEnabled())" ,
375
383
endpointRulesSpecUtils .clientContextParamsName ())
376
- .endControlFlow ()
377
384
.build ());
378
385
}
379
386
}
0 commit comments