Gabriel39 commented on code in PR #71205:
URL: https://github.com/apache/doris/pull/71205#discussion_r4794053265


##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,368 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.filesystem.properties;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their 
authentication clients. */
+public final class StorageEndpointProperties {
+    private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+            "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+    private static final List<String> S3_REGION_ALIASES = List.of("s3.region", 
"AWS_REGION", "region", "REGION",
+            "aws.region", "glue.region", "aws.glue.region", 
"iceberg.rest.signing-region", "rest.signing-region",
+            "client.region");
+    private static final List<String> S3_ENDPOINT_ALIASES = 
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+            "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+    private static final List<String> GCS_ENDPOINT_ALIASES = List.of(
+            "gs.endpoint", "s3.endpoint", "AWS_ENDPOINT", "endpoint", 
"ENDPOINT");
+    private static final List<String> S3_GUESS_REGION_ALIASES = 
List.of("s3.region", "glue.region",
+            "aws.glue.region", "iceberg.rest.signing-region", 
"rest.signing-region", "client.region");
+    private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+            Pattern.compile(
+                    "^(?:https?://)?(?:"
+                            + 
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+                            + "s3express-control\\.([a-z0-9-]+)|"
+                            + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+                            + ")\\.amazonaws\\.com(?:/.*)?$",
+                    Pattern.CASE_INSENSITIVE),
+            Pattern.compile(
+                    
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+                    Pattern.CASE_INSENSITIVE)
+    };
+
+    private StorageEndpointProperties() {
+    }
+
+    public static Map<String, List<String>> derivedEndpointValues(Map<String, 
String> properties) {
+        Map<String, List<String>> result = new 
LinkedHashMap<>(derivedS3EndpointValues(properties));
+        // One alias can bind several selected clients; a normalized OSS peer 
must not replace S3/GCS's peer.
+        for (Map<String, List<String>> endpoints : List.of(
+                derivedGcsEndpointValues(properties), 
OssEndpointProperties.derivedEndpointValues(properties))) {
+            endpoints.forEach((key, values) -> result.merge(key, values, 
(existing, added) -> {
+                List<String> combined = new ArrayList<>(existing);
+                combined.addAll(added);
+                return combined;
+            }));
+        }
+        return result;
+    }
+
+    private static Map<String, List<String>> 
derivedGcsEndpointValues(Map<String, String> properties) {
+        String key = usesGcs(properties) ? firstNonblankKey(properties, 
GCS_ENDPOINT_ALIASES) : null;
+        if (key == null) {
+            return Map.of();
+        }
+        String endpoint = properties.get(key).trim();
+        return Map.of(key, List.of(endpoint.contains("://") ? endpoint : 
"https://"; + endpoint));
+    }
+
+    private static boolean usesS3(Map<String, String> properties) {
+        return "true".equalsIgnoreCase(properties.get("fs.s3.support"))
+                || (!hasExplicitFilesystem(properties) && 
matchesS3Guess(properties));
+    }
+
+    private static boolean usesGcs(Map<String, String> properties) {
+        return "true".equalsIgnoreCase(properties.get("fs.gcs.support"))
+                || (!hasExplicitFilesystem(properties) && 
!GcsEndpointProperties.hasExplicitS3Request(properties)
+                && GcsEndpointProperties.guessIsGcs(properties));
+    }
+
+    public static boolean hasExplicitFilesystem(Map<String, String> 
properties) {
+        return "true".equalsIgnoreCase(properties.get("oss.hdfs.enabled"))
+                || properties.entrySet().stream().anyMatch(entry -> 
entry.getKey() != null
+                        && entry.getKey().startsWith("fs.") && 
entry.getKey().endsWith(".support")
+                        && "true".equalsIgnoreCase(entry.getValue()));
+    }
+
+    private static Map<String, List<String>> 
derivedS3EndpointValues(Map<String, String> properties) {
+        // Region binding alone does not select S3: native OSS also accepts 
legacy AWS region aliases.
+        if (!usesS3(properties)) {
+            return Map.of();
+        }
+        String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
+        String endpointKey = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+        String sourceKey = endpointKey;
+        String endpoint = endpointKey == null ? null : 
properties.get(endpointKey).trim();
+        if (regionKey == null && endpointKey == null) {
+            // The binder's legacy URI fallback runs on its HashMap snapshot, 
including URI key aliases.
+            Map<String, String> raw = new HashMap<>(properties);
+            sourceKey = raw.keySet().stream().filter(key -> 
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+            if (sourceKey == null) {
+                return Map.of();
+            }
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));
+            String forceKey = firstNonblankKey(properties, 
List.of("force_parsing_by_standard_uri"));
+            endpoint = LegacyS3Uri.deriveEndpointQuietly(raw,
+                    pathKey == null ? "false" : properties.get(pathKey).trim(),
+                    forceKey == null ? "false" : 
properties.get(forceKey).trim());
+        }
+        if (endpointKey == null && regionKey == null && endpoint != null
+                && !endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+            // Ordinary legacy resource URIs also bind an endpoint; 
S3ObjStorage supplies HTTPS to bare authorities.
+            return s3RegionFromEndpoint(endpoint).isPresent()
+                    ? Map.of(sourceKey, List.of("https://"; + endpoint)) : 
Map.of();
+        }
+        if (endpoint != null && 
!endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+            // Ordinary explicit endpoints remain active even if another 
provider rewrites this same alias.
+            return Map.of(endpointKey, List.of(endpoint.contains("://") ? 
endpoint : "https://"; + endpoint));
+        }
+        // Glue normalization infers a missing region before rewriting the S3 
endpoint. Reuse the
+        // storage binder's inference and retain the original peer for callers 
that also contact Glue.
+        String region = regionKey == null
+                ? (endpoint == null ? "" : 
s3RegionFromEndpoint(endpoint).orElse(""))
+                : properties.get(regionKey).trim();
+        if (region.isEmpty()) {
+            return Map.of();
+        }
+        if (!region.matches("[A-Za-z0-9-]+")) {
+            throw new IllegalArgumentException("S3 region must be a literal 
hostname component");
+        }
+        String serviceEndpoint = s3EndpointForRegion(region);
+        if (regionKey != null) {
+            return Map.of(regionKey, List.of(serviceEndpoint));
+        }
+        String source = properties.get(sourceKey);
+        String normalized = source.trim().toLowerCase(Locale.ROOT);
+        // An S3 URI is a resource locator; its rewritten endpoint is the 
socket peer. An HTTP URI
+        // can also name the catalog service, so retain that independently 
checked original peer.
+        boolean originalPeer = endpointKey != null || 
normalized.startsWith("http://";)
+                || normalized.startsWith("https://";);
+        return Map.of(sourceKey, originalPeer ? List.of(source, 
serviceEndpoint) : List.of(serviceEndpoint));
+    }
+
+    /** Raw provider guessing shared with binding; first-non-null alias and 
URI precedence are significant. */
+    public static boolean matchesS3Guess(Map<String, String> properties) {
+        if (GcsEndpointProperties.hasExplicitS3Request(properties)) {
+            return true;
+        }
+        if (GcsEndpointProperties.guessIsGcs(properties)) {
+            return false;
+        }
+        String endpoint = null;
+        for (String key : S3_ENDPOINT_ALIASES) {
+            String value = properties.get(key);
+            if (value != null) {
+                endpoint = value;
+                break;
+            }
+        }
+        if (endpoint != null && !endpoint.isBlank()) {
+            return endpoint.contains("amazonaws.com");
+        }
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            if ("uri".equalsIgnoreCase(entry.getKey()) && entry.getValue() != 
null) {
+                return entry.getValue().contains("amazonaws.com");
+            }
+        }
+        for (String key : S3_GUESS_REGION_ALIASES) {
+            String value = properties.get(key);
+            if (value != null && !value.isBlank()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String s3EndpointForRegion(String region) {
+        return "https://s3."; + region + ".amazonaws.com";
+    }
+
+    public static Optional<String> s3RegionFromEndpoint(String endpoint) {
+        String lowerEndpoint = endpoint.toLowerCase(Locale.ROOT);
+        for (Pattern pattern : S3_ENDPOINT_PATTERNS) {
+            Matcher matcher = pattern.matcher(lowerEndpoint);
+            if (matcher.matches()) {
+                for (int i = 1; i <= matcher.groupCount(); i++) {
+                    String group = matcher.group(i);
+                    if (group != null && !group.isBlank()) {
+                        return Optional.of(group);
+                    }
+                }
+            }
+        }
+        return Optional.empty();
+    }
+
+    private static String firstNonblankKey(Map<String, String> properties, 
List<String> aliases) {
+        for (String key : aliases) {
+            String value = properties.get(key);
+            // Match the String binder: trim-empty control bytes must not 
retire a live fallback alias.
+            if (value != null && !value.trim().isEmpty()) {
+                return key;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Selected S3/GCS clients supply HTTPS; other shared aliases require an 
explicit scheme or port.
+     * @throws IllegalArgumentException if a proxy route cannot be established 
from independent endpoint values
+     */
+    public static Map<String, Integer> endpoints(Map<String, String> 
properties, Predicate<String> opaqueCredential) {
+        Map<String, Integer> endpoints = new LinkedHashMap<>();
+        // OSS-HDFS prefers its specific alias over oss.endpoint before 
emitting fs.oss.endpoint.
+        for (String key : new String[] {"s3.endpoint", "AWS_ENDPOINT", 
"endpoint", "ENDPOINT", "aws.endpoint",
+                "glue.endpoint", "aws.glue.endpoint", "oss.endpoint", 
"oss.hdfs.endpoint", "OSS_ENDPOINT",
+                "fs.oss.endpoint", "cos.endpoint", "COS_ENDPOINT",
+                "obs.endpoint", "OBS_ENDPOINT", "azure.endpoint", 
"AZURE_ENDPOINT", "azure.oauth2_server_uri",
+                "azure.oauth2_account_host", "gs.endpoint", "minio.endpoint", 
"ozone.endpoint", "fs.s3a.endpoint",
+                "fs.gs.proxy.address"}) {
+            if (properties.containsKey(key)) {
+                endpoints.put(key, -1);
+            }
+        }
+        // Both native GCS Hadoop and the HMAC S3 adapter prefix bare GCS 
endpoints with HTTPS.
+        if (properties.containsKey("gs.endpoint")) {
+            endpoints.put("gs.endpoint", 443);
+        }
+        // Only a selected client's bound alias has a known HTTPS default. 
Other shared options can
+        // still feed independent metadata clients, whose interpretation is 
checked by their provider.
+        if (usesS3(properties)) {
+            String key = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+            if (key != null) {
+                endpoints.put(key, 443);
+            }
+        }
+        if (usesGcs(properties)) {
+            String key = firstNonblankKey(properties, GCS_ENDPOINT_ALIASES);
+            if (key != null) {
+                endpoints.put(key, 443);
+            }
+        }
+        if (usesS3(properties) || usesGcs(properties)) {

Review Comment:
   Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
   
   Native OSS alias retirement now follows its actual selected alias list, 
independently of whether a region was inferred. An unused OSS_ENDPOINT stays 
dormant behind oss.endpoint; clearing the preferred alias rechecks the 
fallback. Separate metadata and raw Hadoop sinks remain admitted independently. 
Unit, CREATE/ALTER gate and SQL sequences cover dormancy, activation and 
retained configuration.
   
   The current head passed 3023 FE tests, strict FE Checkstyle, a fresh FE 
build, and both local SQL suites. Scope and verification limits are recorded in 
the PR description.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,368 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.filesystem.properties;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their 
authentication clients. */
+public final class StorageEndpointProperties {
+    private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+            "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+    private static final List<String> S3_REGION_ALIASES = List.of("s3.region", 
"AWS_REGION", "region", "REGION",
+            "aws.region", "glue.region", "aws.glue.region", 
"iceberg.rest.signing-region", "rest.signing-region",
+            "client.region");
+    private static final List<String> S3_ENDPOINT_ALIASES = 
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+            "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+    private static final List<String> GCS_ENDPOINT_ALIASES = List.of(
+            "gs.endpoint", "s3.endpoint", "AWS_ENDPOINT", "endpoint", 
"ENDPOINT");
+    private static final List<String> S3_GUESS_REGION_ALIASES = 
List.of("s3.region", "glue.region",
+            "aws.glue.region", "iceberg.rest.signing-region", 
"rest.signing-region", "client.region");
+    private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+            Pattern.compile(
+                    "^(?:https?://)?(?:"
+                            + 
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+                            + "s3express-control\\.([a-z0-9-]+)|"
+                            + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+                            + ")\\.amazonaws\\.com(?:/.*)?$",
+                    Pattern.CASE_INSENSITIVE),
+            Pattern.compile(
+                    
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+                    Pattern.CASE_INSENSITIVE)
+    };
+
+    private StorageEndpointProperties() {
+    }
+
+    public static Map<String, List<String>> derivedEndpointValues(Map<String, 
String> properties) {
+        Map<String, List<String>> result = new 
LinkedHashMap<>(derivedS3EndpointValues(properties));
+        // One alias can bind several selected clients; a normalized OSS peer 
must not replace S3/GCS's peer.
+        for (Map<String, List<String>> endpoints : List.of(
+                derivedGcsEndpointValues(properties), 
OssEndpointProperties.derivedEndpointValues(properties))) {
+            endpoints.forEach((key, values) -> result.merge(key, values, 
(existing, added) -> {
+                List<String> combined = new ArrayList<>(existing);
+                combined.addAll(added);
+                return combined;
+            }));
+        }
+        return result;
+    }
+
+    private static Map<String, List<String>> 
derivedGcsEndpointValues(Map<String, String> properties) {
+        String key = usesGcs(properties) ? firstNonblankKey(properties, 
GCS_ENDPOINT_ALIASES) : null;
+        if (key == null) {
+            return Map.of();
+        }
+        String endpoint = properties.get(key).trim();
+        return Map.of(key, List.of(endpoint.contains("://") ? endpoint : 
"https://"; + endpoint));
+    }
+
+    private static boolean usesS3(Map<String, String> properties) {
+        return "true".equalsIgnoreCase(properties.get("fs.s3.support"))
+                || (!hasExplicitFilesystem(properties) && 
matchesS3Guess(properties));
+    }
+
+    private static boolean usesGcs(Map<String, String> properties) {
+        return "true".equalsIgnoreCase(properties.get("fs.gcs.support"))
+                || (!hasExplicitFilesystem(properties) && 
!GcsEndpointProperties.hasExplicitS3Request(properties)
+                && GcsEndpointProperties.guessIsGcs(properties));
+    }
+
+    public static boolean hasExplicitFilesystem(Map<String, String> 
properties) {
+        return "true".equalsIgnoreCase(properties.get("oss.hdfs.enabled"))
+                || properties.entrySet().stream().anyMatch(entry -> 
entry.getKey() != null
+                        && entry.getKey().startsWith("fs.") && 
entry.getKey().endsWith(".support")
+                        && "true".equalsIgnoreCase(entry.getValue()));
+    }
+
+    private static Map<String, List<String>> 
derivedS3EndpointValues(Map<String, String> properties) {
+        // Region binding alone does not select S3: native OSS also accepts 
legacy AWS region aliases.
+        if (!usesS3(properties)) {
+            return Map.of();
+        }
+        String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
+        String endpointKey = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+        String sourceKey = endpointKey;
+        String endpoint = endpointKey == null ? null : 
properties.get(endpointKey).trim();
+        if (regionKey == null && endpointKey == null) {
+            // The binder's legacy URI fallback runs on its HashMap snapshot, 
including URI key aliases.
+            Map<String, String> raw = new HashMap<>(properties);
+            sourceKey = raw.keySet().stream().filter(key -> 
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+            if (sourceKey == null) {
+                return Map.of();
+            }
+            String pathKey = firstNonblankKey(properties, 
List.of("use_path_style", "s3.path-style-access"));
+            String forceKey = firstNonblankKey(properties, 
List.of("force_parsing_by_standard_uri"));
+            endpoint = LegacyS3Uri.deriveEndpointQuietly(raw,
+                    pathKey == null ? "false" : properties.get(pathKey).trim(),
+                    forceKey == null ? "false" : 
properties.get(forceKey).trim());
+        }
+        if (endpointKey == null && regionKey == null && endpoint != null
+                && !endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+            // Ordinary legacy resource URIs also bind an endpoint; 
S3ObjStorage supplies HTTPS to bare authorities.
+            return s3RegionFromEndpoint(endpoint).isPresent()
+                    ? Map.of(sourceKey, List.of("https://"; + endpoint)) : 
Map.of();
+        }
+        if (endpoint != null && 
!endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+            // Ordinary explicit endpoints remain active even if another 
provider rewrites this same alias.
+            return Map.of(endpointKey, List.of(endpoint.contains("://") ? 
endpoint : "https://"; + endpoint));
+        }
+        // Glue normalization infers a missing region before rewriting the S3 
endpoint. Reuse the
+        // storage binder's inference and retain the original peer for callers 
that also contact Glue.
+        String region = regionKey == null
+                ? (endpoint == null ? "" : 
s3RegionFromEndpoint(endpoint).orElse(""))
+                : properties.get(regionKey).trim();
+        if (region.isEmpty()) {
+            return Map.of();
+        }
+        if (!region.matches("[A-Za-z0-9-]+")) {
+            throw new IllegalArgumentException("S3 region must be a literal 
hostname component");
+        }
+        String serviceEndpoint = s3EndpointForRegion(region);
+        if (regionKey != null) {
+            return Map.of(regionKey, List.of(serviceEndpoint));
+        }
+        String source = properties.get(sourceKey);
+        String normalized = source.trim().toLowerCase(Locale.ROOT);
+        // An S3 URI is a resource locator; its rewritten endpoint is the 
socket peer. An HTTP URI
+        // can also name the catalog service, so retain that independently 
checked original peer.
+        boolean originalPeer = endpointKey != null || 
normalized.startsWith("http://";)
+                || normalized.startsWith("https://";);
+        return Map.of(sourceKey, originalPeer ? List.of(source, 
serviceEndpoint) : List.of(serviceEndpoint));
+    }
+
+    /** Raw provider guessing shared with binding; first-non-null alias and 
URI precedence are significant. */
+    public static boolean matchesS3Guess(Map<String, String> properties) {
+        if (GcsEndpointProperties.hasExplicitS3Request(properties)) {
+            return true;
+        }
+        if (GcsEndpointProperties.guessIsGcs(properties)) {
+            return false;
+        }
+        String endpoint = null;
+        for (String key : S3_ENDPOINT_ALIASES) {
+            String value = properties.get(key);
+            if (value != null) {
+                endpoint = value;
+                break;
+            }
+        }
+        if (endpoint != null && !endpoint.isBlank()) {
+            return endpoint.contains("amazonaws.com");
+        }
+        for (Map.Entry<String, String> entry : properties.entrySet()) {
+            if ("uri".equalsIgnoreCase(entry.getKey()) && entry.getValue() != 
null) {
+                return entry.getValue().contains("amazonaws.com");
+            }
+        }
+        for (String key : S3_GUESS_REGION_ALIASES) {
+            String value = properties.get(key);
+            if (value != null && !value.isBlank()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String s3EndpointForRegion(String region) {
+        return "https://s3."; + region + ".amazonaws.com";
+    }
+
+    public static Optional<String> s3RegionFromEndpoint(String endpoint) {
+        String lowerEndpoint = endpoint.toLowerCase(Locale.ROOT);
+        for (Pattern pattern : S3_ENDPOINT_PATTERNS) {
+            Matcher matcher = pattern.matcher(lowerEndpoint);
+            if (matcher.matches()) {
+                for (int i = 1; i <= matcher.groupCount(); i++) {
+                    String group = matcher.group(i);
+                    if (group != null && !group.isBlank()) {
+                        return Optional.of(group);
+                    }
+                }
+            }
+        }
+        return Optional.empty();
+    }
+
+    private static String firstNonblankKey(Map<String, String> properties, 
List<String> aliases) {
+        for (String key : aliases) {
+            String value = properties.get(key);
+            // Match the String binder: trim-empty control bytes must not 
retire a live fallback alias.
+            if (value != null && !value.trim().isEmpty()) {
+                return key;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Selected S3/GCS clients supply HTTPS; other shared aliases require an 
explicit scheme or port.
+     * @throws IllegalArgumentException if a proxy route cannot be established 
from independent endpoint values
+     */
+    public static Map<String, Integer> endpoints(Map<String, String> 
properties, Predicate<String> opaqueCredential) {
+        Map<String, Integer> endpoints = new LinkedHashMap<>();
+        // OSS-HDFS prefers its specific alias over oss.endpoint before 
emitting fs.oss.endpoint.
+        for (String key : new String[] {"s3.endpoint", "AWS_ENDPOINT", 
"endpoint", "ENDPOINT", "aws.endpoint",
+                "glue.endpoint", "aws.glue.endpoint", "oss.endpoint", 
"oss.hdfs.endpoint", "OSS_ENDPOINT",
+                "fs.oss.endpoint", "cos.endpoint", "COS_ENDPOINT",
+                "obs.endpoint", "OBS_ENDPOINT", "azure.endpoint", 
"AZURE_ENDPOINT", "azure.oauth2_server_uri",
+                "azure.oauth2_account_host", "gs.endpoint", "minio.endpoint", 
"ozone.endpoint", "fs.s3a.endpoint",
+                "fs.gs.proxy.address"}) {
+            if (properties.containsKey(key)) {
+                endpoints.put(key, -1);
+            }
+        }
+        // Both native GCS Hadoop and the HMAC S3 adapter prefix bare GCS 
endpoints with HTTPS.
+        if (properties.containsKey("gs.endpoint")) {
+            endpoints.put("gs.endpoint", 443);
+        }
+        // Only a selected client's bound alias has a known HTTPS default. 
Other shared options can
+        // still feed independent metadata clients, whose interpretation is 
checked by their provider.
+        if (usesS3(properties)) {
+            String key = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+            if (key != null) {
+                endpoints.put(key, 443);
+            }
+        }
+        if (usesGcs(properties)) {
+            String key = firstNonblankKey(properties, GCS_ENDPOINT_ALIASES);
+            if (key != null) {
+                endpoints.put(key, 443);
+            }
+        }
+        if (usesS3(properties) || usesGcs(properties)) {
+            Set<String> selected = new 
HashSet<>(OssEndpointProperties.derivedEndpointValues(properties).keySet());
+            if (usesS3(properties)) {
+                selected.add(firstNonblankKey(properties, 
S3_ENDPOINT_ALIASES));
+            }
+            if (usesGcs(properties)) {
+                selected.add(firstNonblankKey(properties, 
GCS_ENDPOINT_ALIASES));
+            }
+            // Retained aliases are dormant for typed storage; metadata and 
raw Hadoop have separate sinks.
+            for (List<String> aliases : List.of(S3_ENDPOINT_ALIASES, 
GCS_ENDPOINT_ALIASES)) {
+                aliases.stream().filter(key -> 
!selected.contains(key)).forEach(endpoints::remove);

Review Comment:
   Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
   
   The retained alias set now includes every selected stock consumer: 
S3/GCS/OSS/OSS-HDFS/Azure/COS/OBS/MinIO/Ozone. Each selected client also keeps 
its own derived peer, so native OSS rewrites cannot replace another client’s 
destination. COS’s forced HTTPS and the remaining clients’ bare-host/legacy-URI 
rules are covered. GCS co-selection is tested with all five additional 
families, and native OSS co-selection with COS/OBS/MinIO/Ozone; SQL has exact 
CREATE peer controls and rejected-activation retention sequences. Unknown 
support names keep conservative checking.
   
   The current head passed 3023 FE tests, strict FE Checkstyle, a fresh FE 
build, and both local SQL suites. Scope and verification limits are recorded in 
the PR description.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to