Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ public Builder impressionsDedupeTimeInterval(long impressionsDedupeTimeInterval)
* @param rolloutCacheConfiguration Configuration object
* @return This builder
*/
Builder rolloutCacheConfiguration(@NonNull RolloutCacheConfiguration rolloutCacheConfiguration) {
public Builder rolloutCacheConfiguration(@NonNull RolloutCacheConfiguration rolloutCacheConfiguration) {
if (rolloutCacheConfiguration == null) {
Logger.w("Rollout cache configuration is null. Setting to default value.");
mRolloutCacheConfiguration = RolloutCacheConfiguration.builder().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.split.android.client.service.splits;

import static io.split.android.client.utils.Utils.checkNotNull;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand All @@ -9,8 +11,6 @@
import io.split.android.client.storage.splits.SplitsStorage;
import io.split.android.client.utils.logger.Logger;

import static io.split.android.client.utils.Utils.checkNotNull;

/**
* This task is responsible for loading the feature flags, saved filter & saved flags spec values
* from the persistent storage into the in-memory storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ void performProxyCheck() {
long lastProxyCheckTimestamp = getLastProxyCheckTimestamp();

if (lastProxyCheckTimestamp == 0L) {
Logger.v("Never checked proxy; continuing with latest spec");
updateHandlingType(ProxyHandlingType.NONE);
} else if (System.currentTimeMillis() - lastProxyCheckTimestamp > mProxyCheckIntervalMillis) {
Logger.i("Time since last check elapsed. Attempting recovery with latest spec: " + mLatestSpec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void updateSplits(SplitRoomDatabase splitDatabase, GeneralInfoDao genera
}

GeneralInfoEntity trafficTypesEntity = generalInfoDao.getByName(GeneralInfoEntity.TRAFFIC_TYPES_MAP);
if (trafficTypesEntity != null) {
if (trafficTypesEntity != null && !trafficTypesEntity.getStringValue().isEmpty()) {
String fromTrafficTypes = mFromCipher.decrypt(trafficTypesEntity.getStringValue());
String toTrafficTypes = mToCipher.encrypt(fromTrafficTypes);
if (toTrafficTypes != null) {
Expand All @@ -246,7 +246,7 @@ private void updateSplits(SplitRoomDatabase splitDatabase, GeneralInfoDao genera
}

GeneralInfoEntity flagSetsEntity = generalInfoDao.getByName(GeneralInfoEntity.FLAG_SETS_MAP);
if (flagSetsEntity != null) {
if (flagSetsEntity != null && !flagSetsEntity.getStringValue().isEmpty()) {
String fromFlagSets = mFromCipher.decrypt(flagSetsEntity.getStringValue());
String toFlagSets = mToCipher.encrypt(fromFlagSets);
if (toFlagSets != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void run() {
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.CHANGE_NUMBER_INFO, -1));
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.FLAG_SETS_MAP, ""));
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.TRAFFIC_TYPES_MAP, ""));
mDatabase.getSplitQueryDao().invalidate();
mDatabase.splitDao().deleteAll();
}
});
Expand Down Expand Up @@ -258,14 +259,14 @@ public void run() {

private synchronized void parseTrafficTypesAndSets(@Nullable GeneralInfoEntity trafficTypesEntity, @Nullable GeneralInfoEntity flagSetsEntity) {
Logger.v("Parsing traffic types and sets");
if (trafficTypesEntity != null) {
if (trafficTypesEntity != null && !trafficTypesEntity.getStringValue().isEmpty()) {
Type mapType = new TypeToken<Map<String, Integer>>(){}.getType();
String encryptedTrafficTypes = trafficTypesEntity.getStringValue();
String decryptedTrafficTypes = mCipher.decrypt(encryptedTrafficTypes);
mTrafficTypes = Json.fromJson(decryptedTrafficTypes, mapType);
}

if (flagSetsEntity != null) {
if (flagSetsEntity != null && !flagSetsEntity.getStringValue().isEmpty()) {
Type flagsMapType = new TypeToken<Map<String, Set<String>>>(){}.getType();
String encryptedFlagSets = flagSetsEntity.getStringValue();
String decryptedFlagSets = mCipher.decrypt(encryptedFlagSets);
Expand All @@ -290,15 +291,19 @@ private void migrateTrafficTypesAndSetsFromStoredData() {
}

// persist TTs
String decryptedTrafficTypes = Json.toJson(mTrafficTypes);
String encryptedTrafficTypes = mCipher.encrypt(decryptedTrafficTypes);
if (mTrafficTypes != null && !mTrafficTypes.isEmpty()) {
String decryptedTrafficTypes = Json.toJson(mTrafficTypes);
String encryptedTrafficTypes = mCipher.encrypt(decryptedTrafficTypes);
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.TRAFFIC_TYPES_MAP, encryptedTrafficTypes));
}

// persist flag sets
String decryptedFlagSets = Json.toJson(mFlagSets);
String encryptedFlagSets = mCipher.encrypt(decryptedFlagSets);
if (mFlagSets != null && !mFlagSets.isEmpty()) {
// persist flag sets
String decryptedFlagSets = Json.toJson(mFlagSets);
String encryptedFlagSets = mCipher.encrypt(decryptedFlagSets);

mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.TRAFFIC_TYPES_MAP, encryptedTrafficTypes));
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.FLAG_SETS_MAP, encryptedFlagSets));
mDatabase.generalInfoDao().update(new GeneralInfoEntity(GeneralInfoEntity.FLAG_SETS_MAP, encryptedFlagSets));
}
} catch (Exception e) {
Logger.e("Failed to migrate traffic types and flag sets", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class SqLitePersistentSplitsStorageTest {
@Mock
private SplitDao mSplitDao;
@Mock
private SplitQueryDao mSplitQueryDao;
@Mock
private SplitCipher mCipher;
private SqLitePersistentSplitsStorage mStorage;
private AutoCloseable mAutoCloseable;
Expand All @@ -56,6 +58,7 @@ public void setUp() {
mAutoCloseable = MockitoAnnotations.openMocks(this);
when(mDatabase.generalInfoDao()).thenReturn(mock(GeneralInfoDao.class));
when(mDatabase.splitDao()).thenReturn(mSplitDao);
when(mDatabase.getSplitQueryDao()).thenReturn(mSplitQueryDao);
doAnswer((Answer<Void>) invocation -> {
((Runnable) invocation.getArgument(0)).run();
return null;
Expand Down Expand Up @@ -201,6 +204,7 @@ public boolean matches(GeneralInfoEntity argument) {
}
}));
verify(mDatabase.splitDao()).deleteAll();
verify(mDatabase.getSplitQueryDao()).invalidate();
}

@Test
Expand Down
Loading