Skip to content

Commit

Permalink
address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle committed Aug 2, 2024
1 parent 3696097 commit 175b82e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ class MParticleOptionsTest : BaseAbstractTest() {
Assert.assertTrue(
com.mparticle.networking.AccessUtils.equals(
options.networkOptions,
com.mparticle.networking.AccessUtils.getDefaultNetworkOptions()
com.mparticle.networking.AccessUtils.defaultNetworkOptions
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package com.mparticle.networking

object AccessUtils {
private var defaultNetworkOptions: NetworkOptions? = null

fun getDefaultNetworkOptions(): NetworkOptions {
defaultNetworkOptions =
NetworkOptionsManager.defaultNetworkOptions()
return defaultNetworkOptions!!
}
val defaultNetworkOptions: NetworkOptions
get() = NetworkOptionsManager.defaultNetworkOptions()

fun equals(networkOptions1: NetworkOptions, networkOptions2: NetworkOptions): Boolean {
if (networkOptions1 === networkOptions2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private synchronized void updateCoreConfig(JSONObject responseJSON, boolean newC
}

if (responseJSON.has(KEY_DIRECT_URL_ROUTING)) {
directUrlRouting = responseJSON.optBoolean(KEY_DIRECT_URL_ROUTING, false);
directUrlRouting = responseJSON.optBoolean(KEY_DIRECT_URL_ROUTING);
editor.putBoolean(KEY_DIRECT_URL_ROUTING, directUrlRouting);
}

Expand Down Expand Up @@ -1288,7 +1288,7 @@ public boolean isDirectUrlRoutingEnabled() {
}

/* When Direct URL Routing is true, we create a new set of baseUrls that include the silo in the urls. mParticle API keys are prefixed with the
silo and a hyphen (ex. "us1-", "us2-", "eu1-"). us1 was the first silo,and before other silos existed, there were no prefixes and all apiKeys
silo and a hyphen (ex. "us1-", "us2-", "eu1-", etc). us1 was the first silo,and before other silos existed, there were no prefixes and all apiKeys
were us1. As such, if we split on a '-' and the resulting array length is 1, then it is an older APIkey that should route to us1.
When splitKey.length is greater than 1, then splitKey[0] will be us1, us2, eu1, au1, or st1, etc as new silos are added*/
public String getPodPrefix() {
Expand All @@ -1300,7 +1300,7 @@ public String getPodPrefix() {
}
} catch (Exception e) {
prefix = "us1";
Logger.error("Error while setting direct URL routing : " + e);
Logger.error("Error while getting pod prefix for direct URL routing : " + e);
}
return prefix;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public static Builder builder() {
return new Builder();
}

public static Builder builder(String podPrefix, boolean enable) {
return new Builder(podPrefix, enable);
}

@Nullable
public static NetworkOptions withNetworkOptions(@Nullable String jsonString) {
if (MPUtility.isEmpty(jsonString)) {
Expand Down Expand Up @@ -138,17 +134,10 @@ public static class Builder {
private Map<Endpoint, DomainMapping> domainMappings = new HashMap<Endpoint, DomainMapping>();
private Boolean pinningDisabledInDevelopment;
private Boolean pinningDisabled;
private String podPrefix = "us1";
private boolean enablePodRedirection = true;

private Builder() {
}

private Builder(String podPrefix, boolean enable){
this.podPrefix = podPrefix;
this.enablePodRedirection = enable;
}

@NonNull
public Builder addDomainMapping(@Nullable DomainMapping domain) {
if (domainMappings == null) {
Expand Down

0 comments on commit 175b82e

Please sign in to comment.