Program: 29473
Project: 29473
Buggy source:
/** 
 * Load all configuration information from the mail resource node in server.xml for the JavaMail Session object within J2EE.
 */
private void loadMailResources(MailResourceIntf mailResource) throws Exception {
  if (mailResource == null) {
    _logger.log(Level.FINE,"String_Node_Str" + mailResource);
    return;
  }
  jndiName=mailResource.getName();
  description=mailResource.getDescription();
  enabled=mailResource.isEnabled();
  storeProtocol=mailResource.getStoreProtocol();
  storeProtocolClass=mailResource.getStoreProtocolClass();
  transportProtocol=mailResource.getTransportProtocol();
  transportProtocolClass=mailResource.getTransportProtocolClass();
  mailHost=mailResource.getMailHost();
  username=mailResource.getUsername();
  mailFrom=mailResource.getMailFrom();
  debug=mailResource.isDebug();
  String storeProtocolClassName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_CLASS;
  String transportProtocolClassName=MAIL_PREFIX + transportProtocol + MAIL_SUFFIX_CLASS;
  mailProperties.put(MAIL_STORE_PROTOCOL,storeProtocol);
  mailProperties.put(MAIL_TRANSPORT_PROTOCOL,transportProtocol);
  mailProperties.put(storeProtocolClassName,storeProtocolClass);
  mailProperties.put(transportProtocolClassName,transportProtocolClass);
  mailProperties.put(MAIL_FROM,mailFrom);
  mailProperties.put(MAIL_DEBUG,(debug ? "String_Node_Str" : "String_Node_Str"));
  Set properties=mailResource.getProperties();
  ResourceProperty property=null;
  String name=null;
  String value=null;
  String protRelatedHostName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_HOST;
  String protRelatedUserName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_USER;
  for (Iterator it=properties.iterator(); it.hasNext(); ) {
    property=(ResourceProperty)it.next();
    name=property.getName();
    value=(String)property.getValue();
    if (name.startsWith(PROP_NAME_PREFIX_LEGACY)) {
      name=name.replace(PROP_NAME_DELIM_LEGACY,MAIL_DELIM);
    }
    if (name.startsWith(MAIL_PREFIX)) {
      if (name.equals(protRelatedHostName)) {
        mailHost=value;
      }
 else       if (name.equals(protRelatedUserName)) {
        username=value;
      }
      mailProperties.put(name,value);
    }
  }
  mailProperties.put(MAIL_HOST,mailHost);
  mailProperties.put(MAIL_USER,username);
}

Fixed version (ground truth):
/** 
 * Load all configuration information from the mail resource node in server.xml for the JavaMail Session object within J2EE.
 */
private void loadMailResources(MailResourceIntf mailResource) throws Exception {
  if (mailResource == null) {
    _logger.log(Level.FINE,"String_Node_Str");
    return;
  }
  jndiName=mailResource.getName();
  description=mailResource.getDescription();
  enabled=mailResource.isEnabled();
  storeProtocol=mailResource.getStoreProtocol();
  storeProtocolClass=mailResource.getStoreProtocolClass();
  transportProtocol=mailResource.getTransportProtocol();
  transportProtocolClass=mailResource.getTransportProtocolClass();
  mailHost=mailResource.getMailHost();
  username=mailResource.getUsername();
  mailFrom=mailResource.getMailFrom();
  debug=mailResource.isDebug();
  String storeProtocolClassName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_CLASS;
  String transportProtocolClassName=MAIL_PREFIX + transportProtocol + MAIL_SUFFIX_CLASS;
  mailProperties.put(MAIL_STORE_PROTOCOL,storeProtocol);
  mailProperties.put(MAIL_TRANSPORT_PROTOCOL,transportProtocol);
  mailProperties.put(storeProtocolClassName,storeProtocolClass);
  mailProperties.put(transportProtocolClassName,transportProtocolClass);
  mailProperties.put(MAIL_FROM,mailFrom);
  mailProperties.put(MAIL_DEBUG,(debug ? "String_Node_Str" : "String_Node_Str"));
  Set properties=mailResource.getProperties();
  ResourceProperty property=null;
  String name=null;
  String value=null;
  String protRelatedHostName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_HOST;
  String protRelatedUserName=MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_USER;
  for (Iterator it=properties.iterator(); it.hasNext(); ) {
    property=(ResourceProperty)it.next();
    name=property.getName();
    value=(String)property.getValue();
    if (name.startsWith(PROP_NAME_PREFIX_LEGACY)) {
      name=name.replace(PROP_NAME_DELIM_LEGACY,MAIL_DELIM);
    }
    if (name.startsWith(MAIL_PREFIX)) {
      if (name.equals(protRelatedHostName)) {
        mailHost=value;
      }
 else       if (name.equals(protRelatedUserName)) {
        username=value;
      }
      mailProperties.put(name,value);
    }
  }
  mailProperties.put(MAIL_HOST,mailHost);
  mailProperties.put(MAIL_USER,username);
}