4141import com .optimizely .ab .android .shared .Client ;
4242import com .optimizely .ab .android .shared .OptlyStorage ;
4343import com .optimizely .ab .android .shared .ServiceScheduler ;
44+ import com .optimizely .ab .android .user_profile .AndroidUserProfile ;
4445import com .optimizely .ab .bucketing .UserProfile ;
4546import com .optimizely .ab .config .parser .ConfigParseException ;
4647import com .optimizely .ab .event .internal .payload .Event ;
47- import com .optimizely .ab .android .user_profile .AndroidUserProfile ;
4848
4949import org .json .JSONObject ;
5050import 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