Skip to content

Commit 6ce1be0

Browse files
Merge pull request #109 from contentstack/fix/DX-7875-v4.2.1-vpn-issue
fix: update Stack class to set URL from config and enhance TestStack with region-specific URL tests
2 parents 0dc4096 + 7812257 commit 6ce1be0

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## Version 4.2.2
4+
5+
### Date: 01-Jun-2026
6+
7+
- Fix: resolved data fetch failure for non-US regions (AZURE_NA, EU, AU, AZURE_EU, GCP_NA, GCP_EU) when connected via VPN by ensuring Stack.URL is correctly synced with the region-specific CDN host after config initialisation.
8+
39
## Version 4.2.1
410

511
### Date: 20-Apr-2026

contentstack/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
ext {
88
PUBLISH_GROUP_ID = 'com.contentstack.sdk'
99
PUBLISH_ARTIFACT_ID = 'android'
10-
PUBLISH_VERSION = '4.2.1'
10+
PUBLISH_VERSION = '4.2.2'
1111
}
1212

1313
android {

contentstack/src/main/java/com/contentstack/sdk/Stack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ protected void setConfig(Config config) {
9898
}
9999
}
100100
String endpoint = config.PROTOCOL + config.URL;
101+
URL = config.URL;
101102
this.config.setEndpoint(endpoint);
102103
client(endpoint);
103104

contentstack/src/test/java/com/contentstack/sdk/TestStack.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import org.robolectric.annotation.Config;
1414

1515
import java.util.Date;
16+
import java.util.HashMap;
1617
import java.util.LinkedHashMap;
18+
import java.util.Map;
1719

1820
import static org.junit.Assert.*;
1921

@@ -360,7 +362,7 @@ public void testStackWithCustomConfig() throws Exception {
360362
@Test
361363
public void testStackWithDifferentRegions() throws Exception {
362364
com.contentstack.sdk.Config.ContentstackRegion[] regions = com.contentstack.sdk.Config.ContentstackRegion.values();
363-
365+
364366
for (com.contentstack.sdk.Config.ContentstackRegion region : regions) {
365367
com.contentstack.sdk.Config config = new com.contentstack.sdk.Config();
366368
config.setRegion(region);
@@ -369,6 +371,36 @@ public void testStackWithDifferentRegions() throws Exception {
369371
}
370372
}
371373

374+
@Test
375+
public void testAzureNaRegionSetsCorrectURL() throws Exception {
376+
com.contentstack.sdk.Config config = new com.contentstack.sdk.Config();
377+
config.setRegion(com.contentstack.sdk.Config.ContentstackRegion.AZURE_NA);
378+
Stack regionalStack = Contentstack.stack(mockContext, "api_key", "token", "env", config);
379+
assertEquals("azure-na-cdn.contentstack.com", regionalStack.URL);
380+
}
381+
382+
@Test
383+
public void testNonUsRegionsSetsCorrectStackURL() throws Exception {
384+
Map<com.contentstack.sdk.Config.ContentstackRegion, String> expectedHosts = new HashMap<>();
385+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.EU, "eu-cdn.contentstack.io");
386+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.AU, "au-cdn.contentstack.com");
387+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.AZURE_NA, "azure-na-cdn.contentstack.com");
388+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.AZURE_EU, "azure-eu-cdn.contentstack.com");
389+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.GCP_NA, "gcp-na-cdn.contentstack.com");
390+
expectedHosts.put(com.contentstack.sdk.Config.ContentstackRegion.GCP_EU, "gcp-eu-cdn.contentstack.com");
391+
392+
for (Map.Entry<com.contentstack.sdk.Config.ContentstackRegion, String> entry : expectedHosts.entrySet()) {
393+
com.contentstack.sdk.Config config = new com.contentstack.sdk.Config();
394+
config.setRegion(entry.getKey());
395+
Stack regionalStack = Contentstack.stack(mockContext, "api_key", "token", "env", config);
396+
assertEquals(
397+
"Stack.URL mismatch for region " + entry.getKey(),
398+
entry.getValue(),
399+
regionalStack.URL
400+
);
401+
}
402+
}
403+
372404
@Test
373405
public void testContentTypeEntryCreation() {
374406
ContentType contentType = stack.contentType("products");

0 commit comments

Comments
 (0)