Program: 28722
Project: 28722
Buggy source:
/** 
 * Initialize template by loading template jar.
 * @throws DomainException If exception occurs in initializing the template jar.
 */
private void initialize() throws DomainException {
  String templateJarPath=(String)_domainConfig.get(DomainConfig.K_TEMPLATE_NAME);
  if (templateJarPath == null || templateJarPath.isEmpty()) {
    String defaultTemplateName=Version.getDefaultDomainTemplate();
    if (defaultTemplateName == null || defaultTemplateName.isEmpty()) {
      throw new DomainException(_strings.get("String_Node_Str"));
    }
    Map<String,String> envProperties=new ASenvPropertyReader().getProps();
    templateJarPath=envProperties.get(SystemPropertyConstants.INSTALL_ROOT_PROPERTY) + File.separator + DEFUALT_TEMPLATE_RELATIVE_PATH+ File.separator+ defaultTemplateName;
  }
  File template=new File(templateJarPath);
  if (!template.exists() || !template.getName().endsWith("String_Node_Str")) {
    throw new DomainException(_strings.get("String_Node_Str",template.getAbsolutePath()));
  }
  try {
    _templateJar=new JarFile(new File(templateJarPath));
    JarEntry je=_templateJar.getJarEntry("String_Node_Str" + DomainConstants.DOMAIN_XML_FILE);
    if (je == null) {
      throw new DomainException(_strings.get("String_Node_Str",DomainConstants.DOMAIN_XML_FILE));
    }
    je=_templateJar.getJarEntry(TEMPLATE_INFO_XML);
    if (je == null) {
      throw new DomainException(_strings.get("String_Node_Str",TEMPLATE_INFO_XML));
    }
    TemplateInfoHolder templateInfoHolder=new TemplateInfoHolder(_templateJar.getInputStream(je),templateJarPath);
    extractedEntries.add(TEMPLATE_INFO_XML);
    je=_templateJar.getJarEntry(STRINGSUBS_FILE);
    StringSubstitutor stringSubstitutor=null;
    if (je != null) {
      stringSubstitutor=StringSubstitutionFactory.createStringSubstitutor(_templateJar.getInputStream(je));
      List<Property> defaultStringSubsProps=stringSubstitutor.getDefaultProperties(PropertyType.PORT);
      for (      Property prop : defaultStringSubsProps) {
        _defaultPortValues.setProperty(prop.getKey(),prop.getValue());
      }
      extractedEntries.add(je.getName());
    }
 else {
      _logger.log(Level.WARNING,_strings.get("String_Node_Str",STRINGSUBS_FILE));
    }
    _domainTempalte=new DomainTemplate(templateInfoHolder,stringSubstitutor,templateJarPath);
    je=_templateJar.getJarEntry("String_Node_Str" + DomainConstants.KEYSTORE_FILE);
    if (je != null) {
      keystoreBytes=new byte[(int)je.getSize()];
      InputStream in=null;
      int count=0;
      try {
        in=_templateJar.getInputStream(je);
        count=in.read(keystoreBytes);
        if (count < keystoreBytes.length) {
          throw new DomainException(_strings.get("String_Node_Str",je.getName()));
        }
      }
  finally {
        if (in != null) {
          in.close();
        }
      }
      extractedEntries.add(je.getName());
    }
  }
 catch (  Exception e) {
    throw new DomainException(e);
  }
}

Fixed version (ground truth):
/** 
 * Initialize template by loading template jar.
 * @throws DomainException If exception occurs in initializing the template jar.
 */
private void initialize() throws DomainException {
  String templateJarPath=(String)_domainConfig.get(DomainConfig.K_TEMPLATE_NAME);
  if (templateJarPath == null || templateJarPath.isEmpty()) {
    String defaultTemplateName=Version.getDefaultDomainTemplate();
    if (defaultTemplateName == null || defaultTemplateName.isEmpty()) {
      throw new DomainException(_strings.get("String_Node_Str"));
    }
    Map<String,String> envProperties=new ASenvPropertyReader().getProps();
    templateJarPath=envProperties.get(SystemPropertyConstants.INSTALL_ROOT_PROPERTY) + File.separator + DEFUALT_TEMPLATE_RELATIVE_PATH+ File.separator+ defaultTemplateName;
  }
  File template=new File(templateJarPath);
  if (!template.exists() || !template.getName().endsWith("String_Node_Str")) {
    throw new DomainException(_strings.get("String_Node_Str",template.getAbsolutePath()));
  }
  try {
    _templateJar=new JarFile(new File(templateJarPath));
    JarEntry je=_templateJar.getJarEntry("String_Node_Str" + DomainConstants.DOMAIN_XML_FILE);
    if (je == null) {
      throw new DomainException(_strings.get("String_Node_Str",DomainConstants.DOMAIN_XML_FILE));
    }
    je=_templateJar.getJarEntry(TEMPLATE_INFO_XML);
    if (je == null) {
      throw new DomainException(_strings.get("String_Node_Str",TEMPLATE_INFO_XML));
    }
    TemplateInfoHolder templateInfoHolder=new TemplateInfoHolder(_templateJar.getInputStream(je),templateJarPath);
    extractedEntries.add(TEMPLATE_INFO_XML);
    je=_templateJar.getJarEntry(STRINGSUBS_FILE);
    StringSubstitutor stringSubstitutor=null;
    if (je != null) {
      stringSubstitutor=StringSubstitutionFactory.createStringSubstitutor(_templateJar.getInputStream(je));
      List<Property> defaultStringSubsProps=stringSubstitutor.getDefaultProperties(PropertyType.PORT);
      for (      Property prop : defaultStringSubsProps) {
        _defaultPortValues.setProperty(prop.getKey(),prop.getValue());
      }
      extractedEntries.add(je.getName());
    }
 else {
      _logger.log(Level.WARNING,_strings.get("String_Node_Str",STRINGSUBS_FILE));
    }
    _domainTempalte=new DomainTemplate(templateInfoHolder,stringSubstitutor,templateJarPath);
    je=_templateJar.getJarEntry("String_Node_Str" + DomainConstants.KEYSTORE_FILE);
    if (je != null) {
      keystoreBytes=new byte[(int)je.getSize()];
      InputStream in=null;
      int count=0;
      try {
        in=_templateJar.getInputStream(je);
        count=in.read(keystoreBytes);
        if (count < keystoreBytes.length) {
          throw new DomainException(_strings.get("String_Node_Str",je.getName()));
        }
      }
  finally {
        if (in != null) {
          in.close();
        }
      }
      extractedEntries.add(je.getName());
    }
    File parentDomainDir=FileUtils.safeGetCanonicalFile(new File(_domainConfig.getRepositoryRoot()));
    createDirectory(parentDomainDir);
  }
 catch (  Exception e) {
    throw new DomainException(e);
  }
}