Program: 48461
Project: 48461
Buggy source:
/** 
 * wrap cache hit, instantiate, connection check and cache add together to simplify currency issue
 * @param appManagerAdd
 * @return
 */
protected synchronized SoftwareManager loadSoftwareManager(AppManagerAdd appManagerAdd){
  if (cache.containsKey(appManagerAdd.getName())) {
    return cache.get(appManagerAdd);
  }
  String factoryClassName=Configuration.getString(configurationPrefix + appManagerAdd.getType());
  if (CommonUtil.isBlank(factoryClassName)) {
    String errMsg=String.format(Messages.getString("String_Node_Str"),appManagerAdd.getType());
    logger.error(errMsg);
    throw new SWMgrCollectorInternalException(null,errMsg);
  }
  logger.info("String_Node_Str" + factoryClassName);
  SoftwareManagerFactory softwareManagerFactory=null;
  try {
    Class<? extends SoftwareManagerFactory> clazz=ReflectionUtils.getClass(factoryClassName,SoftwareManagerFactory.class);
    logger.info("String_Node_Str");
    softwareManagerFactory=ReflectionUtils.newInstance(clazz);
  }
 catch (  Exception e) {
    String errMsg=String.format(Messages.getString("String_Node_Str"),factoryClassName);
    logger.error(errMsg,e);
    throw new SWMgrCollectorInternalException(e,errMsg);
  }
  checkServerConnection(appManagerAdd.getName(),appManagerAdd.getUrl());
  logger.info("String_Node_Str");
  SoftwareManager softwareManager=null;
  try {
    softwareManager=softwareManagerFactory.getSoftwareManager(appManagerAdd.getUrl(),appManagerAdd.getUsername(),appManagerAdd.getPassword().toCharArray(),getPrivateKey());
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + ex.getMessage(),ex);
    throw SoftwareManagerCollectorException.CONNECT_FAILURE(appManagerAdd.getName(),ExceptionUtils.getRootCauseMessage(ex));
  }
  validateSoftwareManager(appManagerAdd.getName(),softwareManager);
  logger.info("String_Node_Str" + appManagerAdd.getName() + "String_Node_Str");
  cache.put(appManagerAdd.getName(),softwareManager);
  return softwareManager;
}

Fixed version (ground truth):
/** 
 * wrap cache hit, instantiate, connection check and cache add together to simplify currency issue
 * @param appManagerAdd
 * @return
 */
protected synchronized SoftwareManager loadSoftwareManager(AppManagerAdd appManagerAdd){
  String appMgrType=appManagerAdd.getType();
  String name=appManagerAdd.getName();
  if (!appMgrType.equals(Constants.IRONFAN)) {
    checkServerConnection(name,appManagerAdd.getUrl());
  }
  if (cache.containsKey(appManagerAdd.getName())) {
    return cache.get(appManagerAdd);
  }
  String factoryClassName=Configuration.getString(configurationPrefix + appManagerAdd.getType());
  if (CommonUtil.isBlank(factoryClassName)) {
    String errMsg=String.format(Messages.getString("String_Node_Str"),appManagerAdd.getType());
    logger.error(errMsg);
    throw new SWMgrCollectorInternalException(null,errMsg);
  }
  logger.info("String_Node_Str" + factoryClassName);
  SoftwareManagerFactory softwareManagerFactory=null;
  try {
    Class<? extends SoftwareManagerFactory> clazz=ReflectionUtils.getClass(factoryClassName,SoftwareManagerFactory.class);
    logger.info("String_Node_Str");
    softwareManagerFactory=ReflectionUtils.newInstance(clazz);
  }
 catch (  Exception e) {
    String errMsg=String.format(Messages.getString("String_Node_Str"),factoryClassName);
    logger.error(errMsg,e);
    throw new SWMgrCollectorInternalException(e,errMsg);
  }
  logger.info("String_Node_Str");
  SoftwareManager softwareManager=null;
  try {
    softwareManager=softwareManagerFactory.getSoftwareManager(appManagerAdd.getUrl(),appManagerAdd.getUsername(),appManagerAdd.getPassword().toCharArray(),getPrivateKey());
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + ex.getMessage(),ex);
    throw SoftwareManagerCollectorException.CONNECT_FAILURE(appManagerAdd.getName(),ExceptionUtils.getRootCauseMessage(ex));
  }
  validateSoftwareManager(appManagerAdd.getName(),softwareManager);
  logger.info("String_Node_Str" + appManagerAdd.getName() + "String_Node_Str");
  cache.put(appManagerAdd.getName(),softwareManager);
  return softwareManager;
}