Skip to content

Commit 8a042c4

Browse files
authored
Merge pull request #487 from Countly/sc_fix
fix: the config
2 parents 48ed671 + 42fc49b commit 8a042c4

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 25.4.2
2+
* Mitigated an issue where latest fetched behavior settings were replacing the current settings instead of merging.
3+
14
## 25.4.1
25
* Improved request queue handling with a built-in backoff mechanism which is enabled by default.
36
* Added "disableBackoffMechanism()" init config method to disable backoff behavior.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ org.gradle.configureondemand=true
2222
android.useAndroidX=true
2323
android.enableJetifier=true
2424
# RELEASE FIELD SECTION
25-
VERSION_NAME=25.4.1
25+
VERSION_NAME=25.4.2
2626
GROUP=ly.count.android
2727
POM_URL=https://github.com/Countly/countly-sdk-android
2828
POM_SCM_URL=https://github.com/Countly/countly-sdk-android

sdk/src/androidTest/java/ly/count/android/sdk/TestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class TestUtils {
4444
public final static String commonAppKey = "appkey";
4545
public final static String commonDeviceId = "1234";
4646
public final static String SDK_NAME = "java-native-android";
47-
public final static String SDK_VERSION = "25.4.1";
47+
public final static String SDK_VERSION = "25.4.2";
4848
public static final int MAX_THREAD_COUNT_PER_STACK_TRACE = 50;
4949

5050
public static class Activity2 extends Activity {

sdk/src/main/java/ly/count/android/sdk/Countly.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ of this software and associated documentation files (the "Software"), to deal
4747
*/
4848
public class Countly {
4949

50-
private final String DEFAULT_COUNTLY_SDK_VERSION_STRING = "25.4.1";
50+
private final String DEFAULT_COUNTLY_SDK_VERSION_STRING = "25.4.2";
5151
/**
5252
* Used as request meta data on every request
5353
*/

sdk/src/main/java/ly/count/android/sdk/ModuleConfiguration.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import androidx.annotation.NonNull;
44
import androidx.annotation.Nullable;
5+
import java.util.Iterator;
56
import org.json.JSONException;
67
import org.json.JSONObject;
78

@@ -235,23 +236,35 @@ void saveAndStoreDownloadedConfig(@NonNull JSONObject config, @NonNull CountlyCo
235236
return;
236237
}
237238

238-
//at this point it is a valid response
239-
latestRetrievedConfigurationFull = config;
240-
String configAsString;
239+
JSONObject newInner = config.optJSONObject(keyRConfig);
240+
if (newInner == null || newInner.length() == 0) {
241+
L.d("[ModuleConfiguration] Config rejected: inner 'c' object is invalid or empty.");
242+
return;
243+
}
241244

245+
// Merge timestamp and version
242246
try {
243-
latestRetrievedConfiguration = config.getJSONObject(keyRConfig);
244-
configAsString = config.toString();
247+
latestRetrievedConfigurationFull.put(keyRTimestamp, config.get(keyRTimestamp));
248+
latestRetrievedConfigurationFull.put(keyRVersion, config.get(keyRVersion));
245249
} catch (JSONException e) {
246-
latestRetrievedConfigurationFull = null;
247-
latestRetrievedConfiguration = null;
250+
L.w("[ModuleConfiguration] saveAndStoreDownloadedConfig, Failed to merge version/timestamp.", e);
251+
}
248252

249-
L.w("[ModuleConfiguration] saveAndStoreDownloadedConfig, Failed retrieving internal config, " + e);
250-
return;
253+
Iterator<String> keys = newInner.keys();
254+
while (keys.hasNext()) {
255+
String key = keys.next();
256+
Object value = newInner.opt(key);
257+
if (value != null && !JSONObject.NULL.equals(value)) {
258+
try {
259+
latestRetrievedConfiguration.put(key, value);
260+
} catch (JSONException e) {
261+
L.w("[ModuleConfiguration] saveAndStoreDownloadedConfig, Failed to merge inner config key: " + key, e);
262+
}
263+
}
251264
}
252265

253-
//save to storage
254-
storageProvider.setServerConfig(configAsString);
266+
// Save updated config
267+
storageProvider.setServerConfig(latestRetrievedConfigurationFull.toString());
255268

256269
//update config variables
257270
updateConfigVariables(clyConfig);

0 commit comments

Comments
 (0)