@@ -58,14 +58,8 @@ public static String buildAuthToken(ApiClient apiClient, String dbUser, String i
5858 expires = DEFAULT_EXPIRES_SECONDS ;
5959 }
6060
61- // Use StandardEndpointProvider to resolve endpoint (handles regionalization + dual-stack)
62- StandardEndpointProvider endpointProvider = new StandardEndpointProvider ();
63- ResolveEndpointOption option = new ResolveEndpointOption ();
64- option .setService (SERVICE_NAME );
65- option .setRegion (apiClient .getRegion ());
66- option .setUseDualStack (apiClient .getUseDualStack ());
67- ResolvedEndpoint resolved = endpointProvider .endpointFor (option );
68- String endpoint = resolved .getEndpoint ();
61+ // Resolve endpoint: prefer user-configured endpoint, fallback to StandardEndpointProvider
62+ String endpoint = getEndpoint (apiClient );
6963
7064 // SSL handling, ResolveEndpointInterceptor dose not support this
7165 String schema = apiClient .getDisableSSL () ? "http" : "https" ;
@@ -95,4 +89,32 @@ public static String buildAuthToken(ApiClient apiClient, String dbUser, String i
9589
9690 return reqCtx .getPresignedUrl ();
9791 }
92+
93+ /**
94+ * Resolve endpoint host from ApiClient.
95+ * If the user has configured a custom endpoint (via apiClient.setEndpoint), it takes priority.
96+ * Strips schema prefix if present to return pure host.
97+ * Falls back to StandardEndpointProvider for region-based resolution when no custom endpoint is set.
98+ *
99+ * @return endpoint host without schema
100+ */
101+ private static String getEndpoint (ApiClient apiClient ) {
102+ if (StringUtils .isNotEmpty (apiClient .getEndpoint ())) {
103+ String ep = apiClient .getEndpoint ();
104+ if (ep .startsWith ("https://" )) {
105+ return ep .substring ("https://" .length ());
106+ }
107+ if (ep .startsWith ("http://" )) {
108+ return ep .substring ("http://" .length ());
109+ }
110+ return ep ;
111+ }
112+ StandardEndpointProvider endpointProvider = new StandardEndpointProvider ();
113+ ResolveEndpointOption option = new ResolveEndpointOption ();
114+ option .setService (SERVICE_NAME );
115+ option .setRegion (apiClient .getRegion ());
116+ option .setUseDualStack (apiClient .getUseDualStack ());
117+ ResolvedEndpoint resolved = endpointProvider .endpointFor (option );
118+ return resolved .getEndpoint ();
119+ }
98120}
0 commit comments