@@ -160,11 +160,11 @@ public void testCentralEndpointWithRegion() throws Throwable {
160160 describe ("Create a client with the central endpoint but also specify region" );
161161 Configuration conf = getConfiguration ();
162162
163- S3Client client = createS3Client (conf , CENTRAL_ENDPOINT , US_WEST_2 , US_WEST_2 , false );
163+ S3Client client = createS3Client (conf , CENTRAL_ENDPOINT , US_WEST_2 , US_EAST_2 , false );
164164
165165 expectInterceptorException (client );
166166
167- client = createS3Client (conf , CENTRAL_ENDPOINT , US_EAST_1 , US_EAST_1 , false );
167+ client = createS3Client (conf , CENTRAL_ENDPOINT , US_EAST_1 , US_EAST_2 , false );
168168
169169 expectInterceptorException (client );
170170 }
@@ -279,6 +279,23 @@ public void testWithVPCE() throws Throwable {
279279 public void testCentralEndpointCrossRegionAccess () throws Throwable {
280280 describe ("Create bucket on different region and access it using central endpoint" );
281281 final Configuration conf = getConfiguration ();
282+ removeBaseAndBucketOverrides (conf , ENDPOINT );
283+
284+ final Configuration newConf = new Configuration (conf );
285+
286+ newConf .set (ENDPOINT , CENTRAL_ENDPOINT );
287+
288+ newFS = new S3AFileSystem ();
289+ newFS .initialize (getFileSystem ().getUri (), newConf );
290+
291+ assertOpsUsingNewFs ();
292+ }
293+
294+ @ Test
295+ public void testCentralEndpointWithNullRegionCrossRegionAccess () throws Throwable {
296+ describe (
297+ "Create bucket on different region and access it using central endpoint and null region" );
298+ final Configuration conf = getConfiguration ();
282299 removeBaseAndBucketOverrides (conf , ENDPOINT , AWS_REGION );
283300
284301 final Configuration newConf = new Configuration (conf );
@@ -288,6 +305,10 @@ public void testCentralEndpointCrossRegionAccess() throws Throwable {
288305 newFS = new S3AFileSystem ();
289306 newFS .initialize (getFileSystem ().getUri (), newConf );
290307
308+ assertOpsUsingNewFs ();
309+ }
310+
311+ private void assertOpsUsingNewFs () throws IOException {
291312 final String file = getMethodName ();
292313 final Path basePath = methodPath ();
293314 final Path srcDir = new Path (basePath , "srcdir" );
@@ -328,7 +349,7 @@ private final class RegionInterceptor implements ExecutionInterceptor {
328349 public void beforeExecution (Context .BeforeExecution context ,
329350 ExecutionAttributes executionAttributes ) {
330351
331- if (endpoint != null && ( !endpoint .endsWith (CENTRAL_ENDPOINT ) || ! US_EAST_2 . equals ( region ) )) {
352+ if (endpoint != null && !endpoint .endsWith (CENTRAL_ENDPOINT )) {
332353 Assertions .assertThat (
333354 executionAttributes .getAttribute (AwsExecutionAttribute .ENDPOINT_OVERRIDDEN ))
334355 .describedAs ("Endpoint not overridden" ).isTrue ();
0 commit comments