Program: 93727
Project: 93727
Buggy source:
/** 
 * Return a metric result about name similarity. It compares 2 strings and return a double comprised between 0 and 1. The greater this metric, the more equal the strings are.
 * @param str1 First of the two  {@link String}s to compare.
 * @param str2 Second of the two  {@link String}s to compare.
 * @return A metric result about name similarity (0 &lt;= value &lt;= 1).
 */
public static double nameSimilarityMetric(String str1,String str2){
  double result=0d;
  final double almostEquals=0.999999d;
  if (str1 != null && str2 != null) {
    if (str1.equals(str2)) {
      result=1d;
    }
 else     if (str1.length() <= 2 && str2.length() <= 2) {
      int equalChars=0;
      final char[] str1Value=str1.toCharArray();
      final char[] str2Value=str2.toCharArray();
      for (int i=0; i < Math.max(str1Value.length,str2Value.length); i++) {
        if (str1Value[i] == str2Value[i]) {
          equalChars++;
        }
      }
      if (str1Value.length != str2Value.length) {
        result=equalChars / (str1Value.length + str2Value.length);
      }
 else {
        result=equalChars * 2d / (str1Value.length + str2Value.length);
      }
    }
 else     if (str1.length() != 1 && str2.length() != 1) {
      final String string1=str1.toLowerCase();
      final String string2=str2.toLowerCase();
      final List<String> pairs1=pairs(string1);
      final List<String> pairs2=pairs(string2);
      final double union=pairs1.size() + pairs2.size();
      pairs1.retainAll(pairs2);
      final int inter=pairs1.size();
      result=inter * 2d / union;
      if (result > 1) {
        result=1;
      }
      if (result == 1d) {
        result=almostEquals;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Return a metric result about name similarity. It compares 2 strings and return a double comprised between 0 and 1. The greater this metric, the more equal the strings are.
 * @param str1 First of the two  {@link String}s to compare.
 * @param str2 Second of the two  {@link String}s to compare.
 * @return A metric result about name similarity (0 &lt;= value &lt;= 1).
 */
public static double nameSimilarityMetric(String str1,String str2){
  double result=0d;
  final double almostEquals=0.999999d;
  if (str1 != null && str2 != null) {
    if (str1.equals(str2)) {
      result=1d;
    }
 else     if (str1.length() <= 2 && str2.length() <= 2) {
      int equalChars=0;
      final char[] str1Value=str1.toCharArray();
      final char[] str2Value=str2.toCharArray();
      for (int i=0; i < Math.max(str1Value.length,str2Value.length); i++) {
        if (str1Value[i] == str2Value[i]) {
          equalChars++;
        }
      }
      if (str1Value.length != str2Value.length) {
        result=(double)equalChars / (double)(str1Value.length + str2Value.length);
      }
 else {
        result=equalChars * 2d / (str1Value.length + str2Value.length);
      }
    }
 else     if (str1.length() != 1 && str2.length() != 1) {
      final String string1=str1.toLowerCase();
      final String string2=str2.toLowerCase();
      final List<String> pairs1=pairs(string1);
      final List<String> pairs2=pairs(string2);
      final double union=pairs1.size() + pairs2.size();
      pairs1.retainAll(pairs2);
      final int inter=pairs1.size();
      result=inter * 2d / union;
      if (result > 1) {
        result=1d;
      }
 else       if (result > almostEquals) {
        result=almostEquals;
      }
    }
  }
  return result;
}