Skip to content

Commit 9554c10

Browse files
authored
(Codegen) Add defaults to the endpointProvider interface method, for customers that have implemented the client interfaces themselves. (#3598)
1 parent 65c3aa4 commit 9554c10

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/poet/builder/BaseClientBuilderInterface.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ private MethodSpec serviceConfigurationConsumerBuilderMethod() {
137137

138138
private MethodSpec endpointProviderMethod() {
139139
return MethodSpec.methodBuilder("endpointProvider")
140-
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
140+
.addModifiers(Modifier.PUBLIC, Modifier.DEFAULT)
141141
.addParameter(endpointRulesSpecUtils.providerInterfaceName(), "endpointProvider")
142-
.addJavadoc("Set the {@link $T} implementation that will be used by the client to determine the endpoint for each "
143-
+ "request. This is optional; if none is provided a default implementation will be used the SDK.",
144-
endpointRulesSpecUtils.providerInterfaceName())
142+
.addJavadoc("Set the {@link $T} implementation that will be used by the client to determine "
143+
+ "the endpoint for each request. This is optional; if none is provided a "
144+
+ "default implementation will be used the SDK.",
145+
endpointRulesSpecUtils.providerInterfaceName())
145146
.returns(TypeVariableName.get("B"))
147+
.addStatement("throw new $T()", UnsupportedOperationException.class)
146148
.build();
147149
}
148150

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-bearer-auth-client-builder-interface.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C>
1515
* Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for
1616
* each request. This is optional; if none is provided a default implementation will be used the SDK.
1717
*/
18-
B endpointProvider(JsonEndpointProvider endpointProvider);
18+
default B endpointProvider(JsonEndpointProvider endpointProvider) {
19+
throw new UnsupportedOperationException();
20+
}
1921

2022
/**
2123
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-interface.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ default B serviceConfiguration(Consumer<ServiceConfiguration.Builder> serviceCon
2222
* Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for
2323
* each request. This is optional; if none is provided a default implementation will be used the SDK.
2424
*/
25-
B endpointProvider(JsonEndpointProvider endpointProvider);
25+
default B endpointProvider(JsonEndpointProvider endpointProvider) {
26+
throw new UnsupportedOperationException();
27+
}
2628

2729
/**
2830
* Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will

0 commit comments

Comments
 (0)