Program: 4711
Project: 4711
Buggy source:
/** 
 * Constructs an   {@link Authorizable} from the given entityString. The entityString must be a representation of anentity similar to  {@link EntityId#toString()} with the exception that the string can contain wildcards (? and *).Note: <ol> <li> The only validation that this class performs on the entityString is that it checks if the string has enough valid parts for the given  {@link #entityType}. It does not check if the entity exists or not. This is required to allow pre grants. </li> <li> CDAP Authorization does not support authorization on versions of   {@link co.cask.cdap.proto.id.ApplicationId}and   {@link co.cask.cdap.proto.id.ArtifactId}. If a version is included while construction an Authorizable through   {@link #fromString(String)} an {@link IllegalArgumentException} will be thrown.</li> </ol>
 * @param entityString the {@link EntityId#toString()} of the entity which may or may not contains wildcards(? or *)
 */
public static Authorizable fromString(String entityString){
  if (entityString == null || entityString.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] typeAndId=entityString.split(EntityId.IDSTRING_TYPE_SEPARATOR,2);
  if (typeAndId.length != 2) {
    throw new IllegalArgumentException(String.format("String_Node_Str",entityString));
  }
  String typeString=typeAndId[0];
  EntityType type=EntityType.valueOf(typeString.toUpperCase());
  String idString=typeAndId[1];
  List<String> idParts;
  if (type != EntityType.KERBEROSPRINCIPAL) {
    idParts=Arrays.asList(EntityId.IDSTRING_PART_SEPARATOR_PATTERN.split(idString));
  }
 else {
    idParts=Collections.singletonList(idString);
  }
  Map<EntityType,String> entityParts=new LinkedHashMap<>();
  checkParts(type,idParts,idParts.size() - 1,entityParts);
  return new Authorizable(type,entityParts);
}

Fixed version (ground truth):
/** 
 * Constructs an   {@link Authorizable} from the given entityString. The entityString must be a representation of anentity similar to  {@link EntityId#toString()} with the exception that the string can contain wildcards (? and *).Note: <ol> <li> The only validation that this class performs on the entityString is that it checks if the string has enough valid parts for the given  {@link #entityType}. It does not check if the entity exists or not. This is required to allow pre grants. </li> <li> CDAP Authorization does not support authorization on versions of   {@link co.cask.cdap.proto.id.ApplicationId}and   {@link co.cask.cdap.proto.id.ArtifactId}. If a version is included while construction an Authorizable through   {@link #fromString(String)} an {@link IllegalArgumentException} will be thrown.</li> </ol>
 * @param entityString the {@link EntityId#toString()} of the entity which may or may not contains wildcards(? or *)
 */
public static Authorizable fromString(String entityString){
  if (entityString == null || entityString.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] typeAndId=entityString.split(EntityId.IDSTRING_TYPE_SEPARATOR,2);
  if (typeAndId.length != 2) {
    throw new IllegalArgumentException(String.format("String_Node_Str",entityString));
  }
  String typeString=typeAndId[0];
  EntityType type=EntityType.valueOf(typeString.toUpperCase());
  String idString=typeAndId[1];
  List<String> idParts=Collections.emptyList();
switch (type) {
case KERBEROSPRINCIPAL:
    idParts=Collections.singletonList(idString);
  break;
case DATASET:
case DATASET_TYPE:
case DATASET_MODULE:
int namespaceSeparatorPos=idString.indexOf(EntityId.IDSTRING_PART_SEPARATOR);
if (namespaceSeparatorPos > 0) {
idParts=new ArrayList<>();
idParts.add(idString.substring(0,namespaceSeparatorPos));
idParts.add(idString.substring(namespaceSeparatorPos + 1));
}
break;
default :
idParts=Arrays.asList(EntityId.IDSTRING_PART_SEPARATOR_PATTERN.split(idString));
}
Map<EntityType,String> entityParts=new LinkedHashMap<>();
checkParts(type,idParts,idParts.size() - 1,entityParts);
return new Authorizable(type,entityParts);
}