This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new b234bd063d2 branch-3.1: [improve](glue)Enforce HTTPS protocol for Glue
endpoint #58306 (#58366)
b234bd063d2 is described below
commit b234bd063d274016d35bc834fc8791704b041915
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Nov 26 10:50:29 2025 +0800
branch-3.1: [improve](glue)Enforce HTTPS protocol for Glue endpoint #58306
(#58366)
Cherry-picked from #58306
Co-authored-by: Calvin Kirs <[email protected]>
---
.../doris/datasource/property/ParamRules.java | 23 ++++++++++++
.../metastore/AWSGlueMetaStoreBaseProperties.java | 4 ++-
.../doris/datasource/property/ParamRulesTest.java | 41 ++++++++++++++++++++++
.../AWSGlueMetaStoreBasePropertiesTest.java | 19 ++++++++--
4 files changed, 83 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/ParamRules.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/ParamRules.java
index 4cf1564cd40..bc364897f6b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/ParamRules.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/ParamRules.java
@@ -20,6 +20,7 @@ package org.apache.doris.datasource.property;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.function.BooleanSupplier;
public class ParamRules {
@@ -218,6 +219,28 @@ public class ParamRules {
return this;
}
+ /**
+ * Add a custom validation rule using a lambda expression.
+ * <p>
+ * The validation rule will be executed when {@link #validate()} is called.
+ * If the condition evaluates to true, an {@link IllegalArgumentException}
will be thrown
+ * with the provided error message.
+ *
+ * @param condition a BooleanSupplier that returns true if validation
should fail
+ * @param errorMessage the error message to throw if condition evaluates
to true
+ * @return this ParamRules instance for chaining
+ *
+ * @see #validate()
+ */
+ public ParamRules check(BooleanSupplier condition, String errorMessage) {
+ rules.add(() -> {
+ if (condition.getAsBoolean()) {
+ throw new IllegalArgumentException(errorMessage);
+ }
+ });
+ return this;
+ }
+
// --------- Utility Methods ----------
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java
index 032e63ae4c4..445b8311f85 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java
@@ -116,7 +116,9 @@ public class AWSGlueMetaStoreBaseProperties {
"glue.access_key and glue.secret_key must be set
together")
.requireAtLeastOne(new String[]{glueAccessKey, glueIAMRole},
"At least one of glue.access_key or glue.role_arn must
be set")
- .require(glueEndpoint, "glue.endpoint must be set");
+ .require(glueEndpoint, "glue.endpoint must be set")
+ .check(() -> StringUtils.isNotBlank(glueEndpoint) &&
!glueEndpoint.startsWith("https://"),
+ "glue.endpoint must use https protocol,please set
glue.endpoint to https://...");
}
private void checkAndInit() {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/ParamRulesTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/ParamRulesTest.java
index afa0614b453..24fb075d15e 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/ParamRulesTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/ParamRulesTest.java
@@ -147,4 +147,45 @@ public class ParamRulesTest {
);
Assertions.assertDoesNotThrow(() -> rightRule3.validate());
}
+
+ @Test
+ void testComplexLambdaValidation() {
+ String username = "alice";
+ String password = "";
+ String email = "[email protected]";
+ int age = 17;
+ int maxAge = 100;
+
+ ParamRules rules = new ParamRules();
+
+ // Add multiple lambda rules
+ rules.check(() -> username == null || username.isEmpty(), "Username
must not be empty")
+ .check(() -> password == null || password.length() < 6,
"Password must be at least 6 characters")
+ .check(() -> !email.contains("@"), "Email must be valid")
+ .check(() -> age < 18 || age > maxAge, "Age must be between 18
and 100")
+ .check(() -> username.equals(email), "Username and email
cannot be the same");
+ // Validate with prefix message
+ IllegalArgumentException ex =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> rules.validate("Validation Failed"));
+ // Check that the error message is prefixed
+ assert ex.getMessage().startsWith("Validation Failed: ");
+ }
+
+ @Test
+ void testComplexLambdaValidationSuccess() {
+ String username = "alice";
+ String password = "password123";
+ String email = "[email protected]";
+ int age = 25;
+ int maxAge = 100;
+ ParamRules rules = new ParamRules();
+ // Should pass without exception
+ Assertions.assertDoesNotThrow(() -> {
+ rules.check(() -> username == null || username.isEmpty(),
"Username must not be empty")
+ .check(() -> password == null || password.length() < 6,
"Password must be at least 6 characters")
+ .check(() -> !email.contains("@"), "Email must be valid")
+ .check(() -> age < 18 || age > maxAge, "Age must be
between 18 and 100")
+ .check(() -> username.equals(email), "Username and email
cannot be the same");
+ });
+ }
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBasePropertiesTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBasePropertiesTest.java
index f091ac31784..f3d9e0490b9 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBasePropertiesTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBasePropertiesTest.java
@@ -28,7 +28,7 @@ public class AWSGlueMetaStoreBasePropertiesTest {
Map<String, String> props = new HashMap<>();
props.put("glue.access_key", "ak");
props.put("glue.secret_key", "sk");
- props.put("glue.endpoint", "glue.us-east-1.amazonaws.com");
+ props.put("glue.endpoint", "https://glue.us-east-1.amazonaws.com");
return props;
}
@@ -103,15 +103,28 @@ public class AWSGlueMetaStoreBasePropertiesTest {
void testInvalidEndpoint() {
Map<String, String> props = baseValidProps();
props.put("glue.endpoint", "http://invalid-endpoint.com");
- Assertions.assertDoesNotThrow(() ->
AWSGlueMetaStoreBaseProperties.of(props));
+ IllegalArgumentException ex = Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> AWSGlueMetaStoreBaseProperties.of(props)
+ );
+ Assertions.assertTrue(ex.getMessage().contains("glue.endpoint must use
https protocol,please set glue.endpoint to https://..."));
+ props.put("glue.endpoint", "http://glue.us-east-1.amazonaws.com");
+ ex = Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> AWSGlueMetaStoreBaseProperties.of(props)
+ );
+ Assertions.assertTrue(ex.getMessage().contains("glue.endpoint must use
https protocol,please set glue.endpoint to https://..."));
}
@Test
void testExtractRegionFailsWhenPatternMatchesButNoRegion() {
Map<String, String> props = baseValidProps();
props.put("glue.endpoint", "glue..amazonaws.com"); // malformed
- Assertions.assertDoesNotThrow(() ->
AWSGlueMetaStoreBaseProperties.of(props)
+ IllegalArgumentException ex = Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> AWSGlueMetaStoreBaseProperties.of(props)
);
+ Assertions.assertTrue(ex.getMessage().contains("glue.endpoint must use
https protocol,please set glue.endpoint to https://..."));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]