Program: 125956
Project: 125956
Buggy source:
/** 
 * DOC check if the repository exist or not
 * @param nexusUrl
 * @param repositoryId
 * @param userName
 * @param password
 * @return
 */
public static boolean checkConnectionStatus(String nexusUrl,String repositoryId,final String userName,final String password){
  final Authenticator defaultAuthenticator=NetworkUtil.getDefaultAuthenticator();
  if (userName != null && !"String_Node_Str".equals(userName)) {
    Authenticator.setDefault(new Authenticator(){
      @Override protected PasswordAuthentication getPasswordAuthentication(){
        return new PasswordAuthentication(userName,password.toCharArray());
      }
    }
);
  }
  int status=-1;
  try {
    if (nexusUrl == null || "String_Node_Str".equals(nexusUrl) || repositoryId == null || "String_Node_Str".equals(repositoryId)) {
      return false;
    }
    String newUrl=nexusUrl;
    if (newUrl.endsWith(NexusConstants.SLASH)) {
      newUrl=newUrl.substring(0,newUrl.length() - 1);
    }
    String urlToCheck=newUrl + NexusConstants.CONTENT_REPOSITORIES + repositoryId;
    URL url=new URL(urlToCheck);
    HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection();
    if (urlConnection instanceof HttpsURLConnection) {
      String userDir=Platform.getInstallLocation().getURL().getPath();
      final SSLSocketFactory socketFactory=SSLUtils.getSSLContext(userDir).getSocketFactory();
      HttpsURLConnection httpsConnection=(HttpsURLConnection)urlConnection;
      httpsConnection.setSSLSocketFactory(socketFactory);
      httpsConnection.setHostnameVerifier(new HostnameVerifier(){
        @Override public boolean verify(        String arg0,        SSLSession arg1){
          return true;
        }
      }
);
    }
    urlConnection.setConnectTimeout(10000);
    urlConnection.setReadTimeout(10000);
    status=urlConnection.getResponseCode();
    if (status == CONNECTION_OK) {
      return true;
    }
  }
 catch (  Exception e) {
  }
 finally {
    Authenticator.setDefault(defaultAuthenticator);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * DOC check if the repository exist or not
 * @param nexusUrl
 * @param repositoryId
 * @param userName
 * @param password
 * @return
 */
public static boolean checkConnectionStatus(String nexusUrl,String repositoryId,final String userName,final String password){
  if (StringUtils.isEmpty(nexusUrl)) {
    return false;
  }
  final Authenticator defaultAuthenticator=NetworkUtil.getDefaultAuthenticator();
  if (userName != null && !"String_Node_Str".equals(userName)) {
    Authenticator.setDefault(new Authenticator(){
      @Override protected PasswordAuthentication getPasswordAuthentication(){
        return new PasswordAuthentication(userName,password.toCharArray());
      }
    }
);
  }
  int status=-1;
  try {
    if (nexusUrl == null || "String_Node_Str".equals(nexusUrl) || repositoryId == null || "String_Node_Str".equals(repositoryId)) {
      return false;
    }
    String newUrl=nexusUrl;
    if (newUrl.endsWith(NexusConstants.SLASH)) {
      newUrl=newUrl.substring(0,newUrl.length() - 1);
    }
    String urlToCheck=newUrl + NexusConstants.CONTENT_REPOSITORIES + repositoryId;
    URL url=new URL(urlToCheck);
    HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection();
    if (urlConnection instanceof HttpsURLConnection) {
      String userDir=Platform.getInstallLocation().getURL().getPath();
      final SSLSocketFactory socketFactory=SSLUtils.getSSLContext(userDir).getSocketFactory();
      HttpsURLConnection httpsConnection=(HttpsURLConnection)urlConnection;
      httpsConnection.setSSLSocketFactory(socketFactory);
      httpsConnection.setHostnameVerifier(new HostnameVerifier(){
        @Override public boolean verify(        String arg0,        SSLSession arg1){
          return true;
        }
      }
);
    }
    IEclipsePreferences node=InstanceScope.INSTANCE.getNode(ORG_TALEND_DESIGNER_CORE);
    int timeout=node.getInt(ITalendCorePrefConstants.NEXUS_TIMEOUT,10000);
    urlConnection.setConnectTimeout(timeout);
    urlConnection.setReadTimeout(timeout);
    status=urlConnection.getResponseCode();
    if (status == CONNECTION_OK) {
      return true;
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    Authenticator.setDefault(defaultAuthenticator);
  }
  return false;
}