Program: 28177
Project: 28177
Buggy source:
public void execute(AdminCommandContext context){
  final ActionReport report=context.getActionReport();
  ActionReport.MessagePart part=report.getTopMessagePart();
  String applicationName=modulename;
  if (appname != null) {
    applicationName=appname;
  }
  try {
    VersioningUtils.checkIdentifier(applicationName);
  }
 catch (  VersioningSyntaxException ex) {
    report.setMessage(ex.getLocalizedMessage());
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (!deployment.isRegistered(applicationName)) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",applicationName));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Application application=applications.getApplication(applicationName);
  if (application.isLifecycleModule()) {
    if (!terse) {
      part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    }
    return;
  }
  ApplicationInfo appInfo=appRegistry.get(applicationName);
  if (appInfo == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",applicationName));
    return;
  }
  com.sun.enterprise.deployment.Application app=appInfo.getMetaData(com.sun.enterprise.deployment.Application.class);
  if (app == null) {
    if (!terse) {
      part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    }
    return;
  }
  Map<String,String> subComponents;
  Map<String,String> subComponentsMap=new HashMap<String,String>();
  if (appname == null) {
    subComponents=getAppLevelComponents(app,type,subComponentsMap);
  }
 else {
    BundleDescriptor bundleDesc=app.getModuleByUri(modulename);
    if (bundleDesc == null) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",appname,modulename));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
    subComponents=getModuleLevelComponents(bundleDesc,type,subComponentsMap);
  }
  if (type != null) {
    if (!type.equals("String_Node_Str") && !type.equals("String_Node_Str")) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",type));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
  List<String> subModuleInfos=new ArrayList<String>();
  if (!app.isVirtual()) {
    subModuleInfos=getSubModulesForEar(app,type);
  }
  int[] longestValue=new int[2];
  for (  Map.Entry<String,String> entry : subComponents.entrySet()) {
    String key=entry.getKey();
    if (key.length() > longestValue[0]) {
      longestValue[0]=key.length();
    }
    String value=entry.getValue();
    if (value.length() > longestValue[1]) {
      longestValue[1]=value.length();
    }
  }
  StringBuilder formattedLineBuf=new StringBuilder();
  for (int j=0; j < 2; j++) {
    longestValue[j]+=2;
    formattedLineBuf.append("String_Node_Str").append(longestValue[j]).append("String_Node_Str");
  }
  String formattedLine=formattedLineBuf.toString();
  if (!terse && subComponents.isEmpty()) {
    part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
  }
  int i=0;
  for (  String key : subComponents.keySet()) {
    ActionReport.MessagePart childPart=part.addChild();
    childPart.setMessage(String.format(formattedLine,new Object[]{key,subComponents.get(key)}));
    if (appname == null && !app.isVirtual()) {
      if (subModuleInfos.get(i) != null) {
        childPart.addProperty("String_Node_Str",subModuleInfos.get(i));
      }
    }
    if (resources) {
      Module module=application.getModule(key);
      if (module != null) {
        ActionReport subReport=report.addSubActionsReport();
        CommandRunner.CommandInvocation inv=commandRunner.getCommandInvocation("String_Node_Str",subReport,context.getSubject());
        final ParameterMap parameters=new ParameterMap();
        parameters.add("String_Node_Str",application.getName());
        parameters.add("String_Node_Str",module.getName());
        inv.parameters(parameters).execute();
        ActionReport.MessagePart subPart=subReport.getTopMessagePart();
        for (        ActionReport.MessagePart cp : subPart.getChildren()) {
          ActionReport.MessagePart resourcesChildPart=childPart.addChild();
          resourcesChildPart.setMessage("String_Node_Str" + cp.getMessage());
        }
      }
    }
    i++;
  }
  Set<String> keys=subComponentsMap.keySet();
  for (  String key : keys) {
    part.addProperty(key,subComponentsMap.get(key));
  }
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}

Fixed version (ground truth):
public void execute(AdminCommandContext context){
  final ActionReport report=context.getActionReport();
  ActionReport.MessagePart part=report.getTopMessagePart();
  String applicationName=modulename;
  if (appname != null) {
    applicationName=appname;
  }
  try {
    VersioningUtils.checkIdentifier(applicationName);
  }
 catch (  VersioningSyntaxException ex) {
    report.setMessage(ex.getLocalizedMessage());
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  if (!deployment.isRegistered(applicationName)) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",applicationName));
    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    return;
  }
  Application application=applications.getApplication(applicationName);
  if (application.isLifecycleModule()) {
    if (!terse) {
      part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    }
    return;
  }
  ApplicationInfo appInfo=appRegistry.get(applicationName);
  if (appInfo == null) {
    report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",applicationName));
    return;
  }
  com.sun.enterprise.deployment.Application app=appInfo.getMetaData(com.sun.enterprise.deployment.Application.class);
  if (app == null) {
    if (!terse) {
      part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
    }
    return;
  }
  Map<String,String> subComponents;
  Map<String,String> subComponentsMap=new HashMap<String,String>();
  if (appname == null) {
    subComponents=getAppLevelComponents(app,type,subComponentsMap);
  }
 else {
    int versionSuffix=modulename.indexOf(':');
    String versionLessModuleName=versionSuffix > 0 ? modulename.substring(0,versionSuffix) : modulename;
    BundleDescriptor bundleDesc=app.getModuleByUri(versionLessModuleName);
    if (bundleDesc == null) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",appname,modulename));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
    subComponents=getModuleLevelComponents(bundleDesc,type,subComponentsMap);
  }
  if (type != null) {
    if (!type.equals("String_Node_Str") && !type.equals("String_Node_Str")) {
      report.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str",type));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      return;
    }
  }
  List<String> subModuleInfos=new ArrayList<String>();
  if (!app.isVirtual()) {
    subModuleInfos=getSubModulesForEar(app,type);
  }
  int[] longestValue=new int[2];
  for (  Map.Entry<String,String> entry : subComponents.entrySet()) {
    String key=entry.getKey();
    if (key.length() > longestValue[0]) {
      longestValue[0]=key.length();
    }
    String value=entry.getValue();
    if (value.length() > longestValue[1]) {
      longestValue[1]=value.length();
    }
  }
  StringBuilder formattedLineBuf=new StringBuilder();
  for (int j=0; j < 2; j++) {
    longestValue[j]+=2;
    formattedLineBuf.append("String_Node_Str").append(longestValue[j]).append("String_Node_Str");
  }
  String formattedLine=formattedLineBuf.toString();
  if (!terse && subComponents.isEmpty()) {
    part.setMessage(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
  }
  int i=0;
  for (  String key : subComponents.keySet()) {
    ActionReport.MessagePart childPart=part.addChild();
    childPart.setMessage(String.format(formattedLine,new Object[]{key,subComponents.get(key)}));
    if (appname == null && !app.isVirtual()) {
      if (subModuleInfos.get(i) != null) {
        childPart.addProperty("String_Node_Str",subModuleInfos.get(i));
      }
    }
    if (resources) {
      Module module=application.getModule(key);
      if (module != null) {
        ActionReport subReport=report.addSubActionsReport();
        CommandRunner.CommandInvocation inv=commandRunner.getCommandInvocation("String_Node_Str",subReport,context.getSubject());
        final ParameterMap parameters=new ParameterMap();
        parameters.add("String_Node_Str",application.getName());
        parameters.add("String_Node_Str",module.getName());
        inv.parameters(parameters).execute();
        ActionReport.MessagePart subPart=subReport.getTopMessagePart();
        for (        ActionReport.MessagePart cp : subPart.getChildren()) {
          ActionReport.MessagePart resourcesChildPart=childPart.addChild();
          resourcesChildPart.setMessage("String_Node_Str" + cp.getMessage());
        }
      }
    }
    i++;
  }
  Set<String> keys=subComponentsMap.keySet();
  for (  String key : keys) {
    part.addProperty(key,subComponentsMap.get(key));
  }
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}