Program: 13589
Project: 13589
Buggy source:
public static void validateUsernames(final List<String> usernames,String role,long dotComBlogId,final ValidateUsernameCallback callback){
  com.wordpress.rest.RestRequest.Listener listener=new RestRequest.Listener(){
    @Override public void onResponse(    JSONObject jsonObject){
      if (jsonObject != null && callback != null) {
        JSONObject errors=jsonObject.optJSONObject("String_Node_Str");
        int errorredUsernameCount=0;
        if (errors != null) {
          for (          String username : usernames) {
            JSONObject userError=errors.optJSONObject(username);
            if (userError == null) {
              continue;
            }
            errorredUsernameCount++;
switch (userError.optString("String_Node_Str")) {
case "String_Node_Str":
switch (userError.optString("String_Node_Str")) {
case "String_Node_Str":
                callback.onUsernameValidation(username,ValidationResult.USER_NOT_FOUND);
              continue;
case "String_Node_Str":
            callback.onUsernameValidation(username,ValidationResult.INVALID_EMAIL);
          continue;
      }
    break;
case "String_Node_Str":
  callback.onUsernameValidation(username,ValidationResult.ALREADY_MEMBER);
continue;
case "String_Node_Str":
callback.onUsernameValidation(username,ValidationResult.ALREADY_FOLLOWING);
continue;
case "String_Node_Str":
callback.onUsernameValidation(username,ValidationResult.BLOCKED_INVITES);
continue;
}
callback.onError();
callback.onValidationFinished();
return;
}
}
JSONArray succeededUsernames=jsonObject.optJSONArray("String_Node_Str");
if (succeededUsernames == null) {
callback.onError();
callback.onValidationFinished();
return;
}
int succeededUsernameCount=0;
for (int i=0; i < succeededUsernames.length(); i++) {
String username=succeededUsernames.optString(i);
if (usernames.contains(username)) {
succeededUsernameCount++;
callback.onUsernameValidation(username,ValidationResult.USER_FOUND);
}
}
if (errorredUsernameCount + succeededUsernameCount != usernames.size()) {
callback.onError();
callback.onValidationFinished();
}
callback.onValidationFinished();
}
}
}
;
RestRequest.ErrorListener errorListener=new RestRequest.ErrorListener(){
@Override public void onErrorResponse(VolleyError volleyError){
AppLog.e(AppLog.T.API,volleyError);
if (callback != null) {
callback.onError();
}
}
}
;
String path=String.format(Locale.US,"String_Node_Str",dotComBlogId);
Map<String,String> params=new HashMap<>();
for (String username : usernames) {
params.put("String_Node_Str" + username + "String_Node_Str",username);
}
params.put("String_Node_Str",role);
WordPress.getRestClientUtilsV1_1().post(path,params,null,listener,errorListener);
}

Fixed version (ground truth):
public static void validateUsernames(final List<String> usernames,String role,long dotComBlogId,final ValidateUsernameCallback callback){
  com.wordpress.rest.RestRequest.Listener listener=new RestRequest.Listener(){
    @Override public void onResponse(    JSONObject jsonObject){
      if (jsonObject != null && callback != null) {
        JSONObject errors=jsonObject.optJSONObject("String_Node_Str");
        int errorredUsernameCount=0;
        if (errors != null) {
          for (          String username : usernames) {
            JSONObject userError=errors.optJSONObject(username);
            if (userError == null) {
              continue;
            }
            errorredUsernameCount++;
switch (userError.optString("String_Node_Str")) {
case "String_Node_Str":
switch (userError.optString("String_Node_Str")) {
case "String_Node_Str":
                callback.onUsernameValidation(username,ValidationResult.INVALID_EMAIL);
              continue;
case "String_Node_Str":
default :
            callback.onUsernameValidation(username,ValidationResult.USER_NOT_FOUND);
          continue;
      }
case "String_Node_Str":
    callback.onUsernameValidation(username,ValidationResult.ALREADY_MEMBER);
  continue;
case "String_Node_Str":
callback.onUsernameValidation(username,ValidationResult.ALREADY_FOLLOWING);
continue;
case "String_Node_Str":
callback.onUsernameValidation(username,ValidationResult.BLOCKED_INVITES);
continue;
}
callback.onError();
callback.onValidationFinished();
return;
}
}
JSONArray succeededUsernames=jsonObject.optJSONArray("String_Node_Str");
if (succeededUsernames == null) {
callback.onError();
callback.onValidationFinished();
return;
}
int succeededUsernameCount=0;
for (int i=0; i < succeededUsernames.length(); i++) {
String username=succeededUsernames.optString(i);
if (usernames.contains(username)) {
succeededUsernameCount++;
callback.onUsernameValidation(username,ValidationResult.USER_FOUND);
}
}
if (errorredUsernameCount + succeededUsernameCount != usernames.size()) {
callback.onError();
callback.onValidationFinished();
}
callback.onValidationFinished();
}
}
}
;
RestRequest.ErrorListener errorListener=new RestRequest.ErrorListener(){
@Override public void onErrorResponse(VolleyError volleyError){
AppLog.e(AppLog.T.API,volleyError);
if (callback != null) {
callback.onError();
}
}
}
;
String path=String.format(Locale.US,"String_Node_Str",dotComBlogId);
Map<String,String> params=new HashMap<>();
for (String username : usernames) {
params.put("String_Node_Str" + username + "String_Node_Str",username);
}
params.put("String_Node_Str",role);
WordPress.getRestClientUtilsV1_1().post(path,params,null,listener,errorListener);
}