Program: 101940
Project: 101940
Buggy source:
/** 
 * Extract an   {@link URL} from the given {@link IConnectionProfile} usingthe given property key and test its connectivity. <p> If the URL requires authentication then the authentication security type, username and password will all be extracted from the {@link IConnectionProfile}. Thus, the values for the authentication should be stored in the connection profile using the keys from  {@link ICredentialsCommon}.
 * @param connectionProfile
 * @param propertyKey
 * @return
 */
public static Exception testURLConnection(IConnectionProfile connectionProfile,final String propertyKey){
  Properties connProperties=connectionProfile.getBaseProperties();
  String xmlFile=connProperties == null ? null : (String)connProperties.get(propertyKey);
  String responseType=IWSProfileConstants.XML;
  if (connProperties != null) {
    if (connProperties.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY) != null) {
      responseType=(String)connProperties.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY);
    }
  }
  try {
    URL url=URLHelper.buildURL(xmlFile);
    boolean resolved=false;
    Map<String,String> connPropMap=new HashMap<String,String>();
    if (connProperties.get(IWSProfileConstants.ACCEPT_PROPERTY_KEY) != null) {
      connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,(String)connProperties.get(IWSProfileConstants.ACCEPT_PROPERTY_KEY));
    }
 else {
      if (responseType.equalsIgnoreCase(IWSProfileConstants.JSON)) {
        connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,IWSProfileConstants.CONTENT_TYPE_JSON_VALUE);
      }
 else {
        connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,IWSProfileConstants.ACCEPT_DEFAULT_VALUE);
      }
    }
    if (connProperties.get(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY) != null) {
      connPropMap.put(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY,(String)connProperties.get(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY));
    }
 else {
      connPropMap.put(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY,IWSProfileConstants.CONTENT_TYPE_DEFAULT_VALUE);
    }
    for (    Object key : connPropMap.keySet()) {
      String keyStr=(String)key;
      if (IWSProfileConstants.AUTHORIZATION_KEY.equalsIgnoreCase(keyStr) || ICredentialsCommon.PASSWORD_PROP_ID.equalsIgnoreCase(keyStr) || ICredentialsCommon.SECURITY_TYPE_ID.equalsIgnoreCase(keyStr)|| ICredentialsCommon.USERNAME_PROP_ID.equalsIgnoreCase(keyStr)|| IWSProfileConstants.END_POINT_URI_PROP_ID.equalsIgnoreCase(keyStr)|| IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY.equalsIgnoreCase(keyStr)|| IWSProfileConstants.ACCEPT_PROPERTY_KEY.equalsIgnoreCase(keyStr)) {
      }
 else {
        connPropMap.put(keyStr,connProperties.getProperty(keyStr));
      }
    }
    String userName=null;
    String password=null;
    userName=connProperties.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
    password=connProperties.getProperty(ICredentialsCommon.PASSWORD_PROP_ID);
    if (connProperties.getProperty(ICredentialsCommon.SECURITY_TYPE_ID).equals(ICredentialsCommon.SecurityType.Digest.name())) {
      resolved=URLHelper.resolveUrlWithDigest(url,userName,password,connPropMap,true);
    }
 else {
      resolved=URLHelper.resolveUrl(url,userName,password,connPropMap,true);
    }
    if (!resolved) {
      throw new Exception(DatatoolsUiConstants.UTIL.getString("String_Node_Str"));
    }
  }
 catch (  Exception ex) {
    return ex;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Extract an   {@link URL} from the given {@link IConnectionProfile} usingthe given property key and test its connectivity. <p> If the URL requires authentication then the authentication security type, username and password will all be extracted from the {@link IConnectionProfile}. Thus, the values for the authentication should be stored in the connection profile using the keys from  {@link ICredentialsCommon}.
 * @param connectionProfile
 * @param propertyKey
 * @return
 */
public static Exception testURLConnection(IConnectionProfile connectionProfile,final String propertyKey){
  Properties connProperties=connectionProfile.getBaseProperties();
  String xmlFile=connProperties == null ? null : (String)connProperties.get(propertyKey);
  String responseType=IWSProfileConstants.XML;
  if (connProperties != null) {
    if (connProperties.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY) != null) {
      responseType=(String)connProperties.get(IWSProfileConstants.RESPONSE_TYPE_PROPERTY_KEY);
    }
  }
  try {
    URL url=URLHelper.buildURL(xmlFile);
    boolean resolved=false;
    Map<String,String> connPropMap=new HashMap<String,String>();
    if (connProperties.get(IWSProfileConstants.ACCEPT_PROPERTY_KEY) != null) {
      connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,(String)connProperties.get(IWSProfileConstants.ACCEPT_PROPERTY_KEY));
    }
 else {
      if (responseType.equalsIgnoreCase(IWSProfileConstants.JSON)) {
        connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,IWSProfileConstants.CONTENT_TYPE_JSON_VALUE);
      }
 else {
        connPropMap.put(IWSProfileConstants.ACCEPT_PROPERTY_KEY,IWSProfileConstants.ACCEPT_DEFAULT_VALUE);
      }
    }
    if (connProperties.get(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY) != null) {
      connPropMap.put(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY,(String)connProperties.get(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY));
    }
 else {
      connPropMap.put(IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY,IWSProfileConstants.CONTENT_TYPE_DEFAULT_VALUE);
    }
    for (    Object key : connPropMap.keySet()) {
      String keyStr=(String)key;
      if (IWSProfileConstants.AUTHORIZATION_KEY.equalsIgnoreCase(keyStr) || ICredentialsCommon.PASSWORD_PROP_ID.equalsIgnoreCase(keyStr) || ICredentialsCommon.SECURITY_TYPE_ID.equalsIgnoreCase(keyStr)|| ICredentialsCommon.USERNAME_PROP_ID.equalsIgnoreCase(keyStr)|| IWSProfileConstants.END_POINT_URI_PROP_ID.equalsIgnoreCase(keyStr)|| IWSProfileConstants.CONTENT_TYPE_PROPERTY_KEY.equalsIgnoreCase(keyStr)|| IWSProfileConstants.ACCEPT_PROPERTY_KEY.equalsIgnoreCase(keyStr)) {
      }
 else {
        connPropMap.put(keyStr,connProperties.getProperty(keyStr));
      }
    }
    String userName=null;
    String password=null;
    userName=connProperties.getProperty(ICredentialsCommon.USERNAME_PROP_ID);
    password=connProperties.getProperty(ICredentialsCommon.PASSWORD_PROP_ID);
    if (ICredentialsCommon.SecurityType.Digest.name().equals(connProperties.getProperty(ICredentialsCommon.SECURITY_TYPE_ID))) {
      resolved=URLHelper.resolveUrlWithDigest(url,userName,password,connPropMap,true);
    }
 else {
      resolved=URLHelper.resolveUrl(url,userName,password,connPropMap,true);
    }
    if (!resolved) {
      throw new Exception(DatatoolsUiConstants.UTIL.getString("String_Node_Str"));
    }
  }
 catch (  Exception ex) {
    return ex;
  }
  return null;
}