Program: 15339
Project: 15339
Buggy source:
ImageManifest(String imageLocation) throws EucalyptusCloudException {
  Context ctx=Contexts.lookup();
  String cleanLocation=imageLocation.replaceAll("String_Node_Str","String_Node_Str");
  this.imageLocation=cleanLocation;
  int index=cleanLocation.indexOf('/');
  if (index < 2 || index + 1 >= cleanLocation.length()) {
    throw new EucalyptusCloudException("String_Node_Str" + imageLocation);
  }
  String bucketName=cleanLocation.substring(0,index);
  String manifestKey=cleanLocation.substring(index + 1);
  final String manifestName=manifestKey.replaceAll("String_Node_Str","String_Node_Str");
  if (!ImageManifests.verifyBucketAcl(bucketName)) {
    throw new EucalyptusCloudException("String_Node_Str");
  }
  this.manifest=ImageManifests.requestManifestData(ctx.getUserFullName(),bucketName,manifestKey);
  try {
    DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    this.inputSource=builder.parse(new ByteArrayInputStream(this.manifest.getBytes()));
  }
 catch (  Exception e) {
    throw new EucalyptusCloudException("String_Node_Str" + bucketName + "String_Node_Str"+ manifestKey,e);
  }
  this.xpath=XPathFactory.newInstance().newXPath();
  this.xpathHelper=new Function<String,String>(){
    @Override public String apply(    String input){
      try {
        return (String)ImageManifest.this.xpath.evaluate(input,ImageManifest.this.inputSource,XPathConstants.STRING);
      }
 catch (      XPathExpressionException ex) {
        return null;
      }
    }
  }
;
  String temp;
  this.name=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : manifestName.replace("String_Node_Str","String_Node_Str");
  this.signature=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : null;
  this.encryptedKey=this.xpathHelper.apply("String_Node_Str");
  this.encryptedIV=this.xpathHelper.apply("String_Node_Str");
  Predicate<Image.Type> checkIdType=new Predicate<Image.Type>(){
    @Override public boolean apply(    Image.Type input){
      String value=ImageManifest.this.xpathHelper.apply(input.getManifestPath());
      if ("String_Node_Str".equals(value) || "String_Node_Str".equals(value) || manifestName.startsWith(input.getNamePrefix())) {
        return true;
      }
 else {
        return false;
      }
    }
  }
;
  String typeInManifest=this.xpathHelper.apply(Image.TYPE_MANIFEST_XPATH);
  this.size=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? Long.parseLong(temp) : -1l;
  this.bundledSize=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? Long.parseLong(temp) : -1l;
  String arch=this.xpathHelper.apply("String_Node_Str");
  this.architecture=Image.Architecture.valueOf(((arch == null) ? "String_Node_Str" : arch));
  if ((checkIdType.apply(Image.Type.kernel) || checkIdType.apply(Image.Type.ramdisk)) && !ctx.hasAdministrativePrivileges()) {
    throw new EucalyptusCloudException("String_Node_Str");
  }
 else {
    if (checkIdType.apply(Image.Type.kernel)) {
      this.imageType=Image.Type.kernel;
      this.platform=Image.Platform.linux;
      this.kernelId=null;
      this.ramdiskId=null;
    }
 else     if (checkIdType.apply(Image.Type.ramdisk)) {
      this.imageType=Image.Type.ramdisk;
      this.platform=Image.Platform.linux;
      this.kernelId=null;
      this.ramdiskId=null;
    }
 else {
      String kId=this.xpathHelper.apply(Image.Type.kernel.getManifestPath());
      String rId=this.xpathHelper.apply(Image.Type.ramdisk.getManifestPath());
      this.imageType=Image.Type.machine;
      if (!manifestName.startsWith(Image.Platform.windows.toString())) {
        this.platform=Image.Platform.linux;
        if (kId != null && kId.startsWith(Image.Type.kernel.getTypePrefix())) {
          ImageManifests.checkPrivileges(this.kernelId);
          this.kernelId=kId;
        }
 else {
          this.kernelId=null;
        }
        if (kId != null && kId.startsWith(Image.Type.kernel.getTypePrefix())) {
          ImageManifests.checkPrivileges(this.ramdiskId);
          this.ramdiskId=rId;
        }
 else {
          this.ramdiskId=null;
        }
      }
 else {
        this.platform=Image.Platform.windows;
        this.kernelId=null;
        this.ramdiskId=null;
      }
    }
  }
}

Fixed version (ground truth):
ImageManifest(String imageLocation) throws EucalyptusCloudException {
  Context ctx=Contexts.lookup();
  String cleanLocation=imageLocation.replaceAll("String_Node_Str","String_Node_Str");
  this.imageLocation=cleanLocation;
  int index=cleanLocation.indexOf('/');
  if (index < 2 || index + 1 >= cleanLocation.length()) {
    throw new EucalyptusCloudException("String_Node_Str" + imageLocation);
  }
  String bucketName=cleanLocation.substring(0,index);
  String manifestKey=cleanLocation.substring(index + 1);
  final String manifestName=manifestKey.replaceAll("String_Node_Str","String_Node_Str");
  if (!ImageManifests.verifyBucketAcl(bucketName)) {
    throw new EucalyptusCloudException("String_Node_Str");
  }
  this.manifest=ImageManifests.requestManifestData(ctx.getUserFullName(),bucketName,manifestKey);
  try {
    DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    this.inputSource=builder.parse(new ByteArrayInputStream(this.manifest.getBytes()));
  }
 catch (  Exception e) {
    throw new EucalyptusCloudException("String_Node_Str" + bucketName + "String_Node_Str"+ manifestKey,e);
  }
  this.xpath=XPathFactory.newInstance().newXPath();
  this.xpathHelper=new Function<String,String>(){
    @Override public String apply(    String input){
      try {
        return (String)ImageManifest.this.xpath.evaluate(input,ImageManifest.this.inputSource,XPathConstants.STRING);
      }
 catch (      XPathExpressionException ex) {
        return null;
      }
    }
  }
;
  String temp;
  this.name=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : manifestName.replace("String_Node_Str","String_Node_Str");
  this.checksum=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : "String_Node_Str";
  this.checksumType=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : "String_Node_Str";
  this.signature=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? temp : null;
  this.encryptedKey=this.xpathHelper.apply("String_Node_Str");
  this.encryptedIV=this.xpathHelper.apply("String_Node_Str");
  Predicate<Image.Type> checkIdType=new Predicate<Image.Type>(){
    @Override public boolean apply(    Image.Type input){
      String value=ImageManifest.this.xpathHelper.apply(input.getManifestPath());
      if ("String_Node_Str".equals(value) || "String_Node_Str".equals(value) || manifestName.startsWith(input.getNamePrefix())) {
        return true;
      }
 else {
        return false;
      }
    }
  }
;
  String typeInManifest=this.xpathHelper.apply(Image.TYPE_MANIFEST_XPATH);
  this.size=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? Long.parseLong(temp) : -1l;
  this.bundledSize=((temp=this.xpathHelper.apply("String_Node_Str")) != null) ? Long.parseLong(temp) : -1l;
  String arch=this.xpathHelper.apply("String_Node_Str");
  this.architecture=Image.Architecture.valueOf(((arch == null) ? "String_Node_Str" : arch));
  try {
    NodeList devMapList=(NodeList)this.xpath.evaluate("String_Node_Str",inputSource,XPathConstants.NODESET);
    for (int i=0; i < devMapList.getLength(); i++) {
      Node node=devMapList.item(i);
      NodeList children=node.getChildNodes();
      String virtualName=null;
      String device=null;
      for (int j=0; j < children.getLength(); j++) {
        Node childNode=children.item(j);
        String nodeType=childNode.getNodeName();
        if ("String_Node_Str".equals(nodeType) && childNode.getTextContent() != null) {
          virtualName=childNode.getTextContent();
        }
 else         if ("String_Node_Str".equals(nodeType) && childNode.getTextContent() != null) {
          device=childNode.getTextContent();
        }
      }
      if (virtualName != null && device != null) {
        if ("String_Node_Str".equals(virtualName)) {
          continue;
        }
 else         if ("String_Node_Str".equals(virtualName)) {
          this.deviceMappings.add(new ManifestDeviceMapping(DeviceMappingType.root,virtualName,device));
        }
 else         if ("String_Node_Str".equals(virtualName)) {
          this.deviceMappings.add(new ManifestDeviceMapping(DeviceMappingType.swap,virtualName,device));
        }
 else         if (virtualName.startsWith("String_Node_Str")) {
          this.deviceMappings.add(new ManifestDeviceMapping(DeviceMappingType.ephemeral,virtualName,device));
        }
      }
    }
  }
 catch (  XPathExpressionException ex) {
    LOG.error(ex,ex);
  }
  if ((checkIdType.apply(Image.Type.kernel) || checkIdType.apply(Image.Type.ramdisk)) && !ctx.hasAdministrativePrivileges()) {
    throw new EucalyptusCloudException("String_Node_Str");
  }
 else {
    if (checkIdType.apply(Image.Type.kernel)) {
      this.imageType=Image.Type.kernel;
      this.platform=Image.Platform.linux;
      this.kernelId=null;
      this.ramdiskId=null;
    }
 else     if (checkIdType.apply(Image.Type.ramdisk)) {
      this.imageType=Image.Type.ramdisk;
      this.platform=Image.Platform.linux;
      this.kernelId=null;
      this.ramdiskId=null;
    }
 else {
      String kId=this.xpathHelper.apply(Image.Type.kernel.getManifestPath());
      String rId=this.xpathHelper.apply(Image.Type.ramdisk.getManifestPath());
      this.imageType=Image.Type.machine;
      if (!manifestName.startsWith(Image.Platform.windows.toString())) {
        this.platform=Image.Platform.linux;
        if (kId != null && kId.startsWith(Image.Type.kernel.getTypePrefix())) {
          ImageManifests.checkPrivileges(this.kernelId);
          this.kernelId=kId;
        }
 else {
          this.kernelId=null;
        }
        if (kId != null && kId.startsWith(Image.Type.kernel.getTypePrefix())) {
          ImageManifests.checkPrivileges(this.ramdiskId);
          this.ramdiskId=rId;
        }
 else {
          this.ramdiskId=null;
        }
      }
 else {
        this.platform=Image.Platform.windows;
        this.kernelId=null;
        this.ramdiskId=null;
      }
    }
  }
}