41
41
import com .optimizely .ab .android .shared .Client ;
42
42
import com .optimizely .ab .android .shared .OptlyStorage ;
43
43
import com .optimizely .ab .android .shared .ServiceScheduler ;
44
+ import com .optimizely .ab .android .user_profile .AndroidUserProfile ;
44
45
import com .optimizely .ab .bucketing .UserProfile ;
45
46
import com .optimizely .ab .config .parser .ConfigParseException ;
46
47
import com .optimizely .ab .event .internal .payload .Event ;
47
- import com .optimizely .ab .android .user_profile .AndroidUserProfile ;
48
48
49
49
import org .json .JSONObject ;
50
50
import org .slf4j .Logger ;
@@ -153,9 +153,10 @@ public OptimizelyClient initialize(@NonNull Context context, @NonNull String dat
153
153
optimizelyClient = buildOptimizely (context , datafile , userProfile );
154
154
} catch (ConfigParseException e ) {
155
155
logger .error ("Unable to parse compiled data file" , e );
156
+ } catch (Exception e ) {
157
+ logger .error ("Unable to build OptimizelyClient instance" , e );
156
158
}
157
159
158
-
159
160
// After instantiating the OptimizelyClient, we will begin the datafile sync so that next time
160
161
// the user can instantiate with the latest datafile
161
162
final Intent intent = new Intent (context .getApplicationContext (), DataFileService .class );
@@ -369,12 +370,16 @@ protected void onPostExecute(UserProfile userProfile) {
369
370
} else {
370
371
logger .info ("No listener to send Optimizely to" );
371
372
}
372
- } catch (ConfigParseException e ) {
373
+ } catch (Exception e ) {
373
374
logger .error ("Unable to build optimizely instance" , e );
374
375
}
375
376
}
376
377
};
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
+ }
378
383
}
379
384
380
385
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
617
622
* @return a {@link Builder} instance
618
623
*/
619
624
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
+ }
621
632
622
633
// AlarmManager doesn't allow intervals less than 60 seconds
623
634
if (dataFileDownloadIntervalTimeUnit .toMillis (dataFileDownloadInterval ) < (60 * 1000 )) {
@@ -634,7 +645,6 @@ public OptimizelyManager build() {
634
645
dataFileDownloadIntervalTimeUnit ,
635
646
Executors .newSingleThreadExecutor (),
636
647
logger );
637
-
638
648
}
639
649
}
640
650
}
0 commit comments