@@ -81,9 +81,11 @@ static void shutDown() {
8181 */
8282 @ SuppressLint ("CommitPrefEdits" )
8383 private ServerRequestQueue (Context c ) {
84+ BranchLogger .v ("Creating ServerRequestQueue " + c );
8485 sharedPref = c .getSharedPreferences ("BNC_Server_Request_Queue" , Context .MODE_PRIVATE );
8586 editor = sharedPref .edit ();
8687 queue = Collections .synchronizedList (new LinkedList <ServerRequest >());
88+ BranchLogger .v ("Created queue " + queue );
8789 }
8890
8991 /**
@@ -321,12 +323,12 @@ void processNextQueueItem(String callingMethodName) {
321323 if (!(req instanceof ServerRequestRegisterInstall ) && !hasUser ()) {
322324 BranchLogger .d ("Branch Error: User session has not been initialized!" );
323325 networkCount_ = 0 ;
324- req .handleFailure (BranchError .ERR_NO_SESSION , "" );
326+ req .handleFailure (BranchError .ERR_NO_SESSION , "Request " + req + " has no session. " );
325327 }
326328 // Determine if a session is needed to execute (SDK-271)
327329 else if (requestNeedsSession (req ) && !isSessionAvailableForRequest ()) {
328330 networkCount_ = 0 ;
329- req .handleFailure (BranchError .ERR_NO_SESSION , "" );
331+ req .handleFailure (BranchError .ERR_NO_SESSION , "Request " + req + " has no session. " );
330332 } else {
331333 executeTimedBranchPostTask (req , Branch .getInstance ().prefHelper_ .getTaskTimeout ());
332334 }
@@ -434,7 +436,7 @@ private void awaitTimedBranchPostTask(CountDownLatch latch, int timeout, BranchP
434436 try {
435437 if (!latch .await (timeout , TimeUnit .MILLISECONDS )) {
436438 postTask .cancel (true );
437- postTask .onPostExecuteInner (new ServerResponse (postTask .thisReq_ .getRequestPath (), ERR_BRANCH_TASK_TIMEOUT , "" , "" ));
439+ postTask .onPostExecuteInner (new ServerResponse (postTask .thisReq_ .getRequestPath (), ERR_BRANCH_TASK_TIMEOUT , "" , "Thread task timed out. Timeout: " + timeout ));
438440 }
439441 } catch (InterruptedException e ) {
440442 BranchLogger .e ("Caught InterruptedException " + e .getMessage ());
@@ -455,8 +457,9 @@ public void handleNewRequest(ServerRequest req) {
455457 BranchLogger .d ("handleNewRequest " + req );
456458 // If Tracking is disabled fail all messages with ERR_BRANCH_TRACKING_DISABLED
457459 if (Branch .getInstance ().getTrackingController ().isTrackingDisabled () && !req .prepareExecuteWithoutTracking ()) {
458- BranchLogger .d ("Requested operation cannot be completed since tracking is disabled [" + req .requestPath_ .getPath () + "]" );
459- req .handleFailure (BranchError .ERR_BRANCH_TRACKING_DISABLED , "" );
460+ String errMsg = "Requested operation cannot be completed since tracking is disabled [" + req .requestPath_ .getPath () + "]" ;
461+ BranchLogger .d (errMsg );
462+ req .handleFailure (BranchError .ERR_BRANCH_TRACKING_DISABLED , errMsg );
460463 return ;
461464 }
462465 //If not initialised put an open or install request in front of this request(only if this needs session)
@@ -514,7 +517,7 @@ protected ServerResponse doInBackground(Void... voids) {
514517 // update queue wait time
515518 thisReq_ .doFinalUpdateOnBackgroundThread ();
516519 if (Branch .getInstance ().getTrackingController ().isTrackingDisabled () && !thisReq_ .prepareExecuteWithoutTracking ()) {
517- return new ServerResponse (thisReq_ .getRequestPath (), BranchError .ERR_BRANCH_TRACKING_DISABLED , "" , "" );
520+ return new ServerResponse (thisReq_ .getRequestPath (), BranchError .ERR_BRANCH_TRACKING_DISABLED , "" , "Tracking is disabled " );
518521 }
519522 String branchKey = Branch .getInstance ().prefHelper_ .getBranchKey ();
520523 ServerResponse result = null ;
@@ -662,7 +665,7 @@ void onRequestFailed(ServerResponse serverResponse, int status) {
662665 //On Network error or Branch is down fail all the pending requests in the queue except
663666 //for request which need to be replayed on failure.
664667 ServerRequestQueue .this .networkCount_ = 0 ;
665- thisReq_ .handleFailure (status , serverResponse .getFailReason () + " " + serverResponse .getMessage ());
668+ thisReq_ .handleFailure (status , serverResponse .getFailReason () + status + " " + serverResponse .getMessage ());
666669 }
667670
668671 boolean unretryableErrorCode = (400 <= status && status <= 451 ) || status == BranchError .ERR_BRANCH_TRACKING_DISABLED ;
0 commit comments