aws / aws/aws-sdk-java-v2

Add a mechanism to identify a service from its Builder (without reflection)

Open
#6,184 2 comments 0 reactions 1 assignee Claimed by @debora-ito View on GitHub
feature-request p3
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

### Describe the feature

There should be a way to uniquely identify a service from its Builder. Direct reflection on the Builder's class or interfaces is heavy handed and cumbersome. In the interim, we have been successfully using reflection to make accessible and call the `protected` method [`AwsDefaultClientBuilder.serviceName()`](https://github.com/aws/aws-sdk-java-v2/blob/master/core/aws-core/src/main/java/software/amazon/awssdk/awscore/client/builder/AwsDefaultClientBuilder.java#L135). The `serviceEndpointPrefix()` method would work equally well.

### Use Case

We have service-specific configuration settings that we apply in a generic way using [`SdkBuilder.applyMutation()`](https://sdk.amazonaws.com/java/api/2.0.0/software/amazon/awssdk/utils/builder/SdkBuilder.html#applyMutation-java.util.function.Consumer-). For example, under certain circumstances, some services need to use one of two different proxy clusters or no proxy server at all. But part of this determination requires that we know what service it is.

### Proposed Solution

Hoist `serviceEndpointPrefix()` and/or `serviceName()` from `AwsDefaultClientBuilder` into an interface like `AwsClientBuilder`.

### Other Information

I haven't really thought through all the implications of moving those methods to `AwsClientBuilder` (or to another interface, or just making the abstract class's methods public). Or whether there's a better way altogether. But I can say that we have been successfully using `serviceName()` for many years, and it would be nice to make this (or something equivalent) better/officially supported.

So let's start the discussion here.

### Acknowledgements

- [x] I may be able to implement this feature request
- [x] This feature might incur a breaking change

### AWS Java SDK version used

All

### JDK version used

All

### Operating System and version

All

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.