Skip to content

Commit 2640de2

Browse files
authored
Release version 1.3.1 (#110)
2 parents 1d7f916 + 0fa33e1 commit 2640de2

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Optimizely Android X SDK Changelog
2+
### 1.3.1
3+
April 25, 2017
4+
5+
- Handle exceptions in top-level APIs
6+
27
### 1.3.0
38
April 12, 2017
49

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public String execute() {
8484
logger.error("Unexpected response from data file cdn, status: {}", status);
8585
return null;
8686
}
87-
} catch (IOException e) {
87+
} catch (Exception e) {
8888
logger.error("Error making request", e);
8989
return null;
9090
} finally {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyClient.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ public boolean isValid() {
120120
public void track(@NonNull String eventName,
121121
@NonNull String userId) {
122122
if (isValid()) {
123-
optimizely.track(eventName, userId);
123+
try {
124+
optimizely.track(eventName, userId);
125+
} catch (Exception e) {
126+
logger.error("Unable to track event", e);
127+
}
124128
} else {
125129
logger.warn("Optimizely is not initialized, could not track event {} for user {}", eventName, userId);
126130
}
@@ -139,8 +143,8 @@ public void track(@NonNull String eventName,
139143
optimizely.track(eventName, userId, attributes);
140144

141145
} else {
142-
logger.warn("Optimizely is not initialized, could not track event {} for user {}" +
143-
" with attributes", eventName, userId);
146+
logger.warn("Optimizely is not initialized, could not track event {} for user {} with attributes",
147+
eventName, userId);
144148
}
145149
}
146150

android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java

+16-6
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
import com.optimizely.ab.android.shared.Client;
4242
import com.optimizely.ab.android.shared.OptlyStorage;
4343
import com.optimizely.ab.android.shared.ServiceScheduler;
44+
import com.optimizely.ab.android.user_profile.AndroidUserProfile;
4445
import com.optimizely.ab.bucketing.UserProfile;
4546
import com.optimizely.ab.config.parser.ConfigParseException;
4647
import com.optimizely.ab.event.internal.payload.Event;
47-
import com.optimizely.ab.android.user_profile.AndroidUserProfile;
4848

4949
import org.json.JSONObject;
5050
import org.slf4j.Logger;
@@ -153,9 +153,10 @@ public OptimizelyClient initialize(@NonNull Context context, @NonNull String dat
153153
optimizelyClient = buildOptimizely(context, datafile, userProfile);
154154
} catch (ConfigParseException e) {
155155
logger.error("Unable to parse compiled data file", e);
156+
} catch (Exception e) {
157+
logger.error("Unable to build OptimizelyClient instance", e);
156158
}
157159

158-
159160
// After instantiating the OptimizelyClient, we will begin the datafile sync so that next time
160161
// the user can instantiate with the latest datafile
161162
final Intent intent = new Intent(context.getApplicationContext(), DataFileService.class);
@@ -369,12 +370,16 @@ protected void onPostExecute(UserProfile userProfile) {
369370
} else {
370371
logger.info("No listener to send Optimizely to");
371372
}
372-
} catch (ConfigParseException e) {
373+
} catch (Exception e) {
373374
logger.error("Unable to build optimizely instance", e);
374375
}
375376
}
376377
};
377-
initUserProfileTask.executeOnExecutor(executor);
378+
try {
379+
initUserProfileTask.executeOnExecutor(executor);
380+
} catch (Exception e) {
381+
logger.error("Unable to initialize the user profile while injecting Optimizely", e);
382+
}
378383
}
379384

380385
private OptimizelyClient buildOptimizely(@NonNull Context context, @NonNull String dataFile, @NonNull UserProfile userProfile) throws ConfigParseException {
@@ -617,7 +622,13 @@ public Builder withDataFileDownloadInterval(long interval, @NonNull TimeUnit tim
617622
* @return a {@link Builder} instance
618623
*/
619624
public OptimizelyManager build() {
620-
final Logger logger = LoggerFactory.getLogger(OptimizelyManager.class);
625+
Logger logger;
626+
try {
627+
logger = LoggerFactory.getLogger(OptimizelyManager.class);
628+
} catch (Exception e) {
629+
logger = LoggerFactory.getLogger("Optly.androidSdk");
630+
logger.error("Unable to generate logger from class");
631+
}
621632

622633
// AlarmManager doesn't allow intervals less than 60 seconds
623634
if (dataFileDownloadIntervalTimeUnit.toMillis(dataFileDownloadInterval) < (60 * 1000)) {
@@ -634,7 +645,6 @@ public OptimizelyManager build() {
634645
dataFileDownloadIntervalTimeUnit,
635646
Executors.newSingleThreadExecutor(),
636647
logger);
637-
638648
}
639649
}
640650
}

0 commit comments

Comments
 (0)