Skip to content

Commit 30532b6

Browse files
Catch all exceptions when updating instrumentation values (#1250)
* Catch all exceptions when getting instrumentation values * Update ServerRequestQueue.java
1 parent c4d950e commit 30532b6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ public JSONObject getPostWithInstrumentationValues(ConcurrentHashMap<String, Str
339339
BranchLogger.d(e.getMessage());
340340
} catch (ConcurrentModificationException ex) {
341341
extendedPost = params_;
342+
} catch (Exception e) {
343+
BranchLogger.v("ServerRequest " + this + " getPostWithInstrumentationValues caught exception: " + e.getMessage());
342344
}
343345
return extendedPost;
344346
}

Branch-SDK/src/main/java/io/branch/referral/ServerRequestQueue.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,15 +517,21 @@ protected ServerResponse doInBackground(Void... voids) {
517517
return new ServerResponse(thisReq_.getRequestPath(), BranchError.ERR_BRANCH_TRACKING_DISABLED, "", "");
518518
}
519519
String branchKey = Branch.getInstance().prefHelper_.getBranchKey();
520-
ServerResponse result;
521-
if (thisReq_.isGetRequest()) {
522-
result = Branch.getInstance().getBranchRemoteInterface().make_restful_get(thisReq_.getRequestUrl(), thisReq_.getGetParams(), thisReq_.getRequestPath(), branchKey);
523-
} else {
524-
BranchLogger.v("Beginning rest post for " + thisReq_);
525-
result = Branch.getInstance().getBranchRemoteInterface().make_restful_post(thisReq_.getPostWithInstrumentationValues(instrumentationExtraData_), thisReq_.getRequestUrl(), thisReq_.getRequestPath(), branchKey);
520+
ServerResponse result = null;
521+
522+
try {
523+
if (thisReq_.isGetRequest()) {
524+
result = Branch.getInstance().getBranchRemoteInterface().make_restful_get(thisReq_.getRequestUrl(), thisReq_.getGetParams(), thisReq_.getRequestPath(), branchKey);
525+
} else {
526+
BranchLogger.v("BranchPostTask doInBackground beginning rest post for " + thisReq_);
527+
result = Branch.getInstance().getBranchRemoteInterface().make_restful_post(thisReq_.getPostWithInstrumentationValues(instrumentationExtraData_), thisReq_.getRequestUrl(), thisReq_.getRequestPath(), branchKey);
528+
}
529+
if (latch_ != null) {
530+
latch_.countDown();
531+
}
526532
}
527-
if (latch_ != null) {
528-
latch_.countDown();
533+
catch (Exception e){
534+
BranchLogger.v("BranchPostTask doInBackground caught exception: " + e.getMessage());
529535
}
530536
return result;
531537
}
@@ -542,7 +548,7 @@ void onPostExecuteInner(ServerResponse serverResponse) {
542548
latch_.countDown();
543549
}
544550
if (serverResponse == null) {
545-
thisReq_.handleFailure(BranchError.ERR_BRANCH_INVALID_REQUEST, "Null response.");
551+
thisReq_.handleFailure(BranchError.ERR_OTHER, "Null response.");
546552
return;
547553
}
548554

0 commit comments

Comments
 (0)