Program: 91869
Project: 91869
Buggy source:
/** 
 * Returns the code of the given type that matches the given name, or optionally returns a new one if none match the name. This method performs the same work than the GeoAPI   {@code CodeList.valueOf(…)} method,except that this method is more tolerant on string comparisons when looking for an existing code: <ul> <li>Name comparisons are case-insensitive.</li> <li>Only  {@linkplain Character#isLetterOrDigit(int) letter and digit} characters are compared.Spaces and punctuation characters like  {@code '_'} and {@code '-'} are ignored.</li></ul> If no match is found, then a new code is created only if the  {@code canCreate} argument is {@code true}. Otherwise this method returns   {@code null}.
 * @param < T >        The compile-time type given as the {@code codeType} parameter.
 * @param codeType   The type of code list.
 * @param name       The name of the code to obtain, or {@code null}.
 * @param canCreate  {@code true} if this method is allowed to create new code.
 * @return A code matching the given name, or {@code null} if the name is nullor if no matching code is found and  {@code canCreate} is {@code false}.
 * @see #getCodeName(CodeList<?>)
 * @see CodeList#valueOf(Class,String)
 */
public static <T extends CodeList<T>>T forCodeName(final Class<T> codeType,String name,final boolean canCreate){
  name=CharSequences.trimWhitespaces(name);
  if (name == null || name.isEmpty()) {
    return null;
  }
  final String typeName=codeType.getName();
  try {
    Class.forName(typeName,true,codeType.getClassLoader());
  }
 catch (  ClassNotFoundException e) {
    throw new TypeNotPresentException(typeName,e);
  }
  return CodeList.valueOf(codeType,new CodeListFilter(name,canCreate));
}

Fixed version (ground truth):
/** 
 * Returns the code of the given type that matches the given name, or optionally returns a new one if none match the name. This method performs the same work than the GeoAPI   {@code CodeList.valueOf(…)} method,except that this method is more tolerant on string comparisons when looking for an existing code: <ul> <li>Name comparisons are case-insensitive.</li> <li>Only  {@linkplain Character#isLetterOrDigit(int) letter and digit} characters are compared.Spaces and punctuation characters like  {@code '_'} and {@code '-'} are ignored.</li></ul> If no match is found, then a new code is created only if the  {@code canCreate} argument is {@code true}. Otherwise this method returns   {@code null}.
 * @param < T >        The compile-time type given as the {@code codeType} parameter.
 * @param codeType   The type of code list.
 * @param name       The name of the code to obtain, or {@code null}.
 * @param canCreate  {@code true} if this method is allowed to create new code.
 * @return A code matching the given name, or {@code null} if the name is nullor if no matching code is found and  {@code canCreate} is {@code false}.
 * @see #getCodeName(CodeList)
 * @see CodeList#valueOf(Class,String)
 */
public static <T extends CodeList<T>>T forCodeName(final Class<T> codeType,String name,final boolean canCreate){
  name=CharSequences.trimWhitespaces(name);
  if (name == null || name.isEmpty()) {
    return null;
  }
  final String typeName=codeType.getName();
  try {
    Class.forName(typeName,true,codeType.getClassLoader());
  }
 catch (  ClassNotFoundException e) {
    throw new TypeNotPresentException(typeName,e);
  }
  return CodeList.valueOf(codeType,new CodeListFilter(name,canCreate));
}