Program: 165040
Project: 165040
Buggy source:
/** 
 * Finish the PayPal flow. Create a   {@link com.braintreepayments.api.models.PayPalAccount}. Parses the URL using the OTC library and attempts to tokenize the result.
 * @param fragment A {@link BraintreeFragment} used to process the request.
 * @param resultCode Result code from the PayPal flow.
 * @param data Intent returned from PayPal flow. Contains the URL to process.
 */
public synchronized static void finishPayWithPayPal(final BraintreeFragment fragment,int resultCode,Intent data){
  try {
    BraintreeBroadcastManager.getInstance(fragment.getActivity()).unregisterReceiver(sBraintreeFragmentBroadcastReceiver);
    Result result=PayPal.getResultFromActivity(fragment.getActivity(),resultCode,data);
    Boolean isCheckout=PayPal.isCheckoutRequest();
    Boolean isAppSwitch=data.hasExtra(PayPalOneTouchActivity.EXTRA_ONE_TOUCH_RESULT);
    ResultType resultType=result.getResultType();
switch (resultType) {
case Error:
      sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
    break;
case Cancel:
  if (result.getError() == null) {
    sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
  }
 else {
    sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
  }
break;
case Success:
sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
PayPalAccountBuilder paypalAccountBuilder=getBuilderFromResponse(fragment.getContext(),resultCode,data);
if (paypalAccountBuilder != null) {
TokenizationClient.tokenize(fragment,paypalAccountBuilder,new PaymentMethodResponseCallback(){
@Override public void success(PaymentMethod paymentMethod){
fragment.postCallback(paymentMethod);
}
@Override public void failure(Exception exception){
fragment.postCallback(exception);
}
}
);
}
break;
}
}
 catch (ConfigurationException ignored) {
}
}

Fixed version (ground truth):
/** 
 * Finish the PayPal flow. Create a   {@link com.braintreepayments.api.models.PayPalAccount}. Parses the URL using the OTC library and attempts to tokenize the result.
 * @param fragment A {@link BraintreeFragment} used to process the request.
 * @param resultCode Result code from the PayPal flow.
 * @param data Intent returned from PayPal flow. Contains the URL to process.
 */
public synchronized static void finishPayWithPayPal(final BraintreeFragment fragment,int resultCode,Intent data){
  try {
    BraintreeBroadcastManager.getInstance(fragment.getActivity()).unregisterReceiver(sBraintreeFragmentBroadcastReceiver);
    Result result=PayPal.getResultFromActivity(fragment.getActivity(),resultCode,data);
    Boolean isCheckout=PayPal.isCheckoutRequest();
    Boolean isAppSwitch=data.hasExtra(PayPalOneTouchActivity.EXTRA_ONE_TOUCH_RESULT);
    ResultType resultType=result.getResultType();
switch (resultType) {
case Error:
      sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
    break;
case Cancel:
  if (result.getError() == null) {
    sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
  }
 else {
    sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
  }
break;
case Success:
sendAnalyticsEventForSwitchResult(fragment,isCheckout,isAppSwitch,"String_Node_Str");
PayPalAccountBuilder paypalAccountBuilder=getBuilderFromResponse(fragment.getApplicationContext(),resultCode,data);
if (paypalAccountBuilder != null) {
TokenizationClient.tokenize(fragment,paypalAccountBuilder,new PaymentMethodResponseCallback(){
@Override public void success(PaymentMethod paymentMethod){
fragment.postCallback(paymentMethod);
}
@Override public void failure(Exception exception){
fragment.postCallback(exception);
}
}
);
}
break;
}
}
 catch (ConfigurationException ignored) {
}
}