Skip to content

Commit

Permalink
[fix](s3) do not replace https scheme if specified (apache#44242)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Problem Summary:
When creating s3 resource with endpoint, it user already specify
`https://` schema in endpoint url,
we should not replace it with `http://`.

### Release note

[fix](s3) fix bug that s3 resource do not support `https://`
  • Loading branch information
morningman authored Nov 19, 2024
1 parent d87c8cc commit def0bc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void setProperties(Map<String, String> properties) throws DdlException

// the endpoint for ping need add uri scheme.
String pingEndpoint = properties.get(S3Properties.ENDPOINT);
if (!pingEndpoint.startsWith("http://")) {
if (!pingEndpoint.startsWith("http://") && !pingEndpoint.startsWith("https://")) {
pingEndpoint = "http://" + properties.get(S3Properties.ENDPOINT);
properties.put(S3Properties.ENDPOINT, pingEndpoint);
properties.put(S3Properties.Env.ENDPOINT, pingEndpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,20 @@ public void testModifyProperties() throws Exception {
modify.put("s3.access_key", "aaa");
s3Resource.modifyProperties(modify);
}

@Test
public void testHttpScheme() throws DdlException {
// if https:// is set, it should be replaced with http://
Map<String, String> properties = new HashMap<>();
properties.put("AWS_ENDPOINT", "https://aaa");
properties.put("AWS_REGION", "bbb");
properties.put("AWS_ROOT_PATH", "/path/to/root");
properties.put("AWS_ACCESS_KEY", "xxx");
properties.put("AWS_SECRET_KEY", "yyy");
properties.put("AWS_BUCKET", "test-bucket");
properties.put("s3_validity_check", "false");
S3Resource s3Resource = new S3Resource("s3_2");
s3Resource.setProperties(properties);
Assert.assertEquals(s3Resource.getProperty(S3Properties.ENDPOINT), "https://aaa");
}
}

0 comments on commit def0bc2

Please sign in to comment.