Program: 35642
Project: 35642
Buggy source:
/** 
 * Deserializes a custom string representation of a profile which has been generated by the   {@link #writeProfile(ProfileDTO)} method.
 * @param string The profile string representation.
 * @return The profile.
 */
public static ProfileDTO readProfile(String string){
  final ProfileDTO profile=new ProfileDTO();
  if (string != null) {
    final int startIndex=string.indexOf(START_TAG);
    final int endIndex=string.indexOf(END_TAG);
    if (startIndex != -1 && endIndex != -1) {
      final String profileAsString=string.substring(startIndex + START_TAG.length(),endIndex);
      final String[] fields=profileAsString.split(FIELD_SEPARATOR);
      if (fields.length >= 3) {
        profile.setName(fields[0]);
        profile.setGlobalPermissions(new HashSet<GlobalPermissionEnum>());
        final String[] globalPermissions=fields[1].split(GLOBAL_PERMISSION_SEPARATOR);
        for (        final String global : globalPermissions) {
          if (global != null) {
            try {
              profile.getGlobalPermissions().add(GlobalPermissionEnum.valueOf(global));
            }
 catch (            IllegalArgumentException e) {
              continue;
            }
          }
        }
        profile.setPrivacyGroups(new HashMap<PrivacyGroupDTO,PrivacyGroupPermissionEnum>());
        final String[] privacyGroups=fields[2].split(PRIVACY_GROUP_SEPARATOR);
        for (        final String group : privacyGroups) {
          if (group != null) {
            final String[] groupProperties=group.split(PRIVACY_GROUP_FIELD_SEPARATOR);
            if (groupProperties.length >= 4) {
              try {
                final PrivacyGroupDTO newGroup=new PrivacyGroupDTO();
                newGroup.setId(Integer.valueOf(groupProperties[0]));
                newGroup.setCode(Integer.valueOf(groupProperties[1]));
                newGroup.setTitle(groupProperties[2]);
                final PrivacyGroupPermissionEnum permission=PrivacyGroupPermissionEnum.valueOf(groupProperties[3]);
                profile.getPrivacyGroups().put(newGroup,permission);
              }
 catch (              NumberFormatException e) {
                continue;
              }
catch (              IllegalArgumentException e) {
                continue;
              }
catch (              NullPointerException e) {
                continue;
              }
            }
          }
        }
      }
    }
  }
  return profile;
}

Fixed version (ground truth):
/** 
 * Deserializes a custom string representation of a profile which has been generated by the   {@link #writeProfile(ProfileDTO)} method.
 * @param string The profile string representation.
 * @return The profile.
 */
public static ProfileDTO readProfile(String string){
  final ProfileDTO profile=new ProfileDTO();
  if (string != null) {
    final int startIndex=string.indexOf(START_TAG);
    final int endIndex=string.indexOf(END_TAG);
    if (startIndex != -1 && endIndex != -1) {
      final String profileAsString=string.substring(startIndex + START_TAG.length(),endIndex);
      final String[] fields=profileAsString.split(FIELD_SEPARATOR);
      if (fields.length >= 1) {
        profile.setName(fields[0]);
        if (fields.length >= 2) {
          profile.setGlobalPermissions(new HashSet<GlobalPermissionEnum>());
          final String[] globalPermissions=fields[1].split(GLOBAL_PERMISSION_SEPARATOR);
          for (          final String global : globalPermissions) {
            if (global != null) {
              try {
                profile.getGlobalPermissions().add(GlobalPermissionEnum.valueOf(global));
              }
 catch (              IllegalArgumentException e) {
                continue;
              }
            }
          }
          if (fields.length >= 3) {
            profile.setPrivacyGroups(new HashMap<PrivacyGroupDTO,PrivacyGroupPermissionEnum>());
            final String[] privacyGroups=fields[2].split(PRIVACY_GROUP_SEPARATOR);
            for (            final String group : privacyGroups) {
              if (group != null) {
                final String[] groupProperties=group.split(PRIVACY_GROUP_FIELD_SEPARATOR);
                if (groupProperties.length >= 4) {
                  try {
                    final PrivacyGroupDTO newGroup=new PrivacyGroupDTO();
                    newGroup.setId(Integer.valueOf(groupProperties[0]));
                    newGroup.setCode(Integer.valueOf(groupProperties[1]));
                    newGroup.setTitle(groupProperties[2]);
                    final PrivacyGroupPermissionEnum permission=PrivacyGroupPermissionEnum.valueOf(groupProperties[3]);
                    profile.getPrivacyGroups().put(newGroup,permission);
                  }
 catch (                  NumberFormatException e) {
                    continue;
                  }
catch (                  IllegalArgumentException e) {
                    continue;
                  }
catch (                  NullPointerException e) {
                    continue;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return profile;
}