Program: 7217
Project: 7217
Buggy source:
/** 
 * pathParts should look like {app-id}/{program-type}/{program-id}/{component-type}/{component-id}.
 */
static void parseSubContext(Iterator<String> pathParts,Map<String,String> tagValues) throws MetricsPathException {
  if (!pathParts.hasNext()) {
    return;
  }
  String pathProgramTypeStr=pathParts.next();
  ProgramType programType;
  try {
    programType=ProgramType.valueOf(pathProgramTypeStr.toUpperCase());
  }
 catch (  IllegalArgumentException e) {
    throw new MetricsPathException("String_Node_Str" + pathProgramTypeStr);
  }
  if (!pathParts.hasNext()) {
    return;
  }
  tagValues.put(programType.getTagName(),pathParts.next());
  if (!pathParts.hasNext()) {
    return;
  }
switch (programType) {
case MAPREDUCE:
    String mrTypeStr=pathParts.next();
  if (mrTypeStr.equals(RUN_ID)) {
    parseRunId(pathParts,tagValues);
    if (pathParts.hasNext()) {
      mrTypeStr=pathParts.next();
    }
 else {
      return;
    }
  }
MapReduceType mrType;
try {
mrType=MapReduceType.valueOf(mrTypeStr.toUpperCase());
}
 catch (IllegalArgumentException e) {
throw new MetricsPathException("String_Node_Str" + mrTypeStr + "String_Node_Str");
}
tagValues.put(Constants.Metrics.Tag.MR_TASK_TYPE,mrType.getId());
break;
case FLOWS:
buildFlowletContext(pathParts,tagValues);
break;
case HANDLERS:
buildComponentTypeContext(pathParts,tagValues,"String_Node_Str","String_Node_Str",Constants.Metrics.Tag.METHOD);
break;
case SERVICES:
buildComponentTypeContext(pathParts,tagValues,"String_Node_Str","String_Node_Str",Constants.Metrics.Tag.SERVICE_RUNNABLE);
break;
case PROCEDURES:
if (pathParts.hasNext()) {
if (pathParts.next().equals(RUN_ID)) {
parseRunId(pathParts,tagValues);
}
}
break;
case SPARK:
if (pathParts.hasNext()) {
if (pathParts.next().equals(RUN_ID)) {
parseRunId(pathParts,tagValues);
}
}
break;
}
if (pathParts.hasNext()) {
throw new MetricsPathException("String_Node_Str");
}
}

Fixed version (ground truth):
/** 
 * pathParts should look like {app-id}/{program-type}/{program-id}/{component-type}/{component-id}.
 */
static void parseSubContext(Iterator<String> pathParts,Map<String,String> tagValues) throws MetricsPathException {
  if (!pathParts.hasNext()) {
    return;
  }
  String pathProgramTypeStr=pathParts.next();
  ProgramType programType;
  try {
    programType=ProgramType.valueOf(pathProgramTypeStr.toUpperCase());
  }
 catch (  IllegalArgumentException e) {
    throw new MetricsPathException("String_Node_Str" + pathProgramTypeStr);
  }
  if (pathParts.hasNext()) {
    tagValues.put(programType.getTagName(),pathParts.next());
  }
 else {
    tagValues.put(programType.getTagName(),null);
  }
  if (!pathParts.hasNext()) {
    return;
  }
switch (programType) {
case MAPREDUCE:
    String mrTypeStr=pathParts.next();
  if (mrTypeStr.equals(RUN_ID)) {
    parseRunId(pathParts,tagValues);
    if (pathParts.hasNext()) {
      mrTypeStr=pathParts.next();
    }
 else {
      return;
    }
  }
MapReduceType mrType;
try {
mrType=MapReduceType.valueOf(mrTypeStr.toUpperCase());
}
 catch (IllegalArgumentException e) {
throw new MetricsPathException("String_Node_Str" + mrTypeStr + "String_Node_Str");
}
tagValues.put(Constants.Metrics.Tag.MR_TASK_TYPE,mrType.getId());
break;
case FLOWS:
buildFlowletContext(pathParts,tagValues);
break;
case HANDLERS:
buildComponentTypeContext(pathParts,tagValues,"String_Node_Str","String_Node_Str",Constants.Metrics.Tag.METHOD);
break;
case SERVICES:
buildComponentTypeContext(pathParts,tagValues,"String_Node_Str","String_Node_Str",Constants.Metrics.Tag.SERVICE_RUNNABLE);
break;
case PROCEDURES:
if (pathParts.hasNext()) {
if (pathParts.next().equals(RUN_ID)) {
parseRunId(pathParts,tagValues);
}
}
break;
case SPARK:
if (pathParts.hasNext()) {
if (pathParts.next().equals(RUN_ID)) {
parseRunId(pathParts,tagValues);
}
}
break;
}
if (pathParts.hasNext()) {
throw new MetricsPathException("String_Node_Str");
}
}