Program: 170806
Project: 170806
Buggy source:
protected long getSizeSupport() throws ResourceDownloaderException {
  try {
    String protocol=original_url.getProtocol().toLowerCase();
    if (protocol.equals("String_Node_Str") || protocol.equals("String_Node_Str") || protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")) {
      return (-1);
    }
 else     if (protocol.equals("String_Node_Str")) {
      return (new File(original_url.toURI()).length());
    }
    reportActivity(this,"String_Node_Str" + original_url);
    try {
      URL url=new URL(original_url.toString().replaceAll("String_Node_Str","String_Node_Str"));
      url=AddressUtils.adjustURL(url);
      URL initial_url=url;
      PluginProxy plugin_proxy;
      boolean ok=false;
      if (auto_plugin_proxy || isAnonymous()) {
        plugin_proxy=AEProxyFactory.getPluginProxy("String_Node_Str",url);
        if (plugin_proxy == null) {
          throw (new ResourceDownloaderException(this,"String_Node_Str"));
        }
        url=plugin_proxy.getURL();
        force_proxy=plugin_proxy.getProxy();
      }
 else {
        plugin_proxy=null;
      }
      try {
        if (force_no_proxy) {
          AEProxySelectorFactory.getSelector().startNoProxy();
        }
        if (auth_supplied) {
          SESecurityManager.setPasswordHandler(url,this);
        }
        boolean dh_hack=false;
        boolean internal_error_hack=false;
        SSLSocketFactory ssl_socket_factory=null;
        for (int connect_loop=0; connect_loop < 2; connect_loop++) {
          try {
            HttpURLConnection con;
            if (url.getProtocol().equalsIgnoreCase("String_Node_Str")) {
              HttpsURLConnection ssl_con=(HttpsURLConnection)openConnection(force_proxy,url);
              if (ssl_socket_factory != null) {
                ssl_con.setSSLSocketFactory(ssl_socket_factory);
              }
              if (!internal_error_hack) {
                ssl_con.setHostnameVerifier(new HostnameVerifier(){
                  @Override public boolean verify(                  String host,                  SSLSession session){
                    return (true);
                  }
                }
);
              }
              if (dh_hack) {
                UrlUtils.DHHackIt(ssl_con);
              }
              if (internal_error_hack && plugin_proxy != null) {
                String host=plugin_proxy.getURLHostRewrite();
                UrlUtils.HTTPSURLConnectionSNIHack(host,ssl_con);
              }
              con=ssl_con;
            }
 else {
              con=(HttpURLConnection)openConnection(force_proxy,url);
            }
            con.setInstanceFollowRedirects(plugin_proxy == null);
            if (plugin_proxy != null) {
              con.setRequestProperty("String_Node_Str",plugin_proxy.getURLHostRewrite() + (initial_url.getPort() == -1 ? "String_Node_Str" : ("String_Node_Str" + initial_url.getPort())));
            }
            con.setRequestMethod("String_Node_Str");
            ClientIDGenerator cidg=ClientIDManagerImpl.getSingleton().getGenerator();
            if (cidg != null) {
              Properties props=new Properties();
              cidg.generateHTTPProperties(null,props);
              String ua=props.getProperty(ClientIDGenerator.PR_USER_AGENT);
              con.setRequestProperty("String_Node_Str",ua);
            }
            setRequestProperties(con,false);
            try {
              con.connect();
            }
 catch (            AEProxyFactory.UnknownHostException e) {
              throw (new UnknownHostException(e.getMessage()));
            }
            int response=con.getResponseCode();
            setProperty("String_Node_Str",new Long(response));
            if ((response != HttpURLConnection.HTTP_ACCEPTED) && (response != HttpURLConnection.HTTP_OK)) {
              if (response == HttpURLConnection.HTTP_MOVED_TEMP || response == HttpURLConnection.HTTP_MOVED_PERM) {
                return (-1);
              }
              URL dest=url;
              if (plugin_proxy != null) {
                try {
                  dest=new URL(plugin_proxy.getTarget());
                }
 catch (                Throwable e) {
                }
              }
              throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(dest) + "String_Node_Str"+ Integer.toString(response)+ "String_Node_Str"+ con.getResponseMessage()));
            }
            getRequestProperties(con);
            ok=true;
            return (UrlUtils.getContentLength(con));
          }
 catch (          SSLException e) {
            String msg=Debug.getNestedExceptionMessage(e);
            if (connect_loop < 3) {
              boolean try_again=false;
              if (msg.contains("String_Node_Str")) {
                if (!dh_hack) {
                  dh_hack=true;
                  try_again=true;
                }
              }
 else               if (msg.contains("String_Node_Str") || msg.contains("String_Node_Str")) {
                if (!internal_error_hack) {
                  internal_error_hack=true;
                  try_again=true;
                }
              }
              ssl_socket_factory=SESecurityManager.installServerCertificates(url);
              if (ssl_socket_factory != null) {
                try_again=true;
              }
              if (try_again) {
                continue;
              }
            }
            throw (e);
          }
catch (          IOException e) {
            if (connect_loop == 0) {
              URL retry_url=UrlUtils.getIPV4Fallback(url);
              if (retry_url != null) {
                url=retry_url;
                continue;
              }
            }
            throw (e);
          }
        }
        throw (new ResourceDownloaderException(this,"String_Node_Str"));
      }
  finally {
        if (auth_supplied) {
          SESecurityManager.setPasswordHandler(url,null);
        }
        if (force_no_proxy) {
          AEProxySelectorFactory.getSelector().endNoProxy();
        }
        if (plugin_proxy != null) {
          plugin_proxy.setOK(ok);
          force_proxy=null;
        }
      }
    }
 catch (    java.net.MalformedURLException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + original_url + "String_Node_Str"+ e.getMessage(),e));
    }
catch (    java.net.UnknownHostException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(original_url) + "String_Node_Str"+ e.getMessage()+ "String_Node_Str",e));
    }
catch (    java.io.IOException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(original_url) + "String_Node_Str",e));
    }
  }
 catch (  Throwable e) {
    ResourceDownloaderException rde;
    if (e instanceof ResourceDownloaderException) {
      rde=(ResourceDownloaderException)e;
    }
 else {
      Debug.out(e);
      rde=new ResourceDownloaderException(this,"String_Node_Str",e);
    }
    throw (rde);
  }
}

Fixed version (ground truth):
protected long getSizeSupport() throws ResourceDownloaderException {
  try {
    String protocol=original_url.getProtocol().toLowerCase();
    if (protocol.equals("String_Node_Str") || protocol.equals("String_Node_Str") || protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")|| protocol.equals("String_Node_Str")) {
      return (-1);
    }
 else     if (protocol.equals("String_Node_Str")) {
      return (new File(original_url.toURI()).length());
    }
    reportActivity(this,"String_Node_Str" + original_url);
    try {
      URL url=new URL(original_url.toString().replaceAll("String_Node_Str","String_Node_Str"));
      url=AddressUtils.adjustURL(url);
      URL initial_url=url;
      PluginProxy plugin_proxy;
      boolean ok=false;
      if (auto_plugin_proxy || isAnonymous()) {
        plugin_proxy=AEProxyFactory.getPluginProxy("String_Node_Str",url);
        if (plugin_proxy == null) {
          throw (new ResourceDownloaderException(this,"String_Node_Str"));
        }
        url=plugin_proxy.getURL();
        force_proxy=plugin_proxy.getProxy();
      }
 else {
        plugin_proxy=null;
      }
      try {
        if (force_no_proxy) {
          AEProxySelectorFactory.getSelector().startNoProxy();
        }
        if (auth_supplied) {
          SESecurityManager.setPasswordHandler(url,this);
        }
        boolean dh_hack=false;
        boolean internal_error_hack=false;
        SSLSocketFactory ssl_socket_factory=null;
        for (int connect_loop=0; connect_loop < 2; connect_loop++) {
          try {
            HttpURLConnection con;
            if (url.getProtocol().equalsIgnoreCase("String_Node_Str")) {
              HttpsURLConnection ssl_con=(HttpsURLConnection)openConnection(force_proxy,url);
              if (ssl_socket_factory != null) {
                ssl_con.setSSLSocketFactory(ssl_socket_factory);
              }
              if (!internal_error_hack) {
                ssl_con.setHostnameVerifier(new HostnameVerifier(){
                  @Override public boolean verify(                  String host,                  SSLSession session){
                    return (true);
                  }
                }
);
              }
              if (plugin_proxy != null) {
                TrustManagerFactory tmf=SESecurityManager.getTrustManagerFactory();
                final List<X509TrustManager> default_tms=new ArrayList<>();
                if (tmf != null) {
                  for (                  TrustManager tm : tmf.getTrustManagers()) {
                    if (tm instanceof X509TrustManager) {
                      default_tms.add((X509TrustManager)tm);
                    }
                  }
                }
                TrustManager[] tms_delegate=SESecurityManager.getAllTrustingTrustManager(new X509TrustManager(){
                  @Override public X509Certificate[] getAcceptedIssuers(){
                    List<X509Certificate> result=new ArrayList<>();
                    for (                    X509TrustManager tm : default_tms) {
                      result.addAll(Arrays.asList(tm.getAcceptedIssuers()));
                    }
                    return (result.toArray(new X509Certificate[result.size()]));
                  }
                  @Override public void checkClientTrusted(                  java.security.cert.X509Certificate[] chain,                  String authType) throws CertificateException {
                    for (                    X509TrustManager tm : default_tms) {
                      tm.checkClientTrusted(chain,authType);
                    }
                  }
                  @Override public void checkServerTrusted(                  java.security.cert.X509Certificate[] chain,                  String authType) throws CertificateException {
                    for (                    X509TrustManager tm : default_tms) {
                      tm.checkServerTrusted(chain,authType);
                    }
                  }
                }
);
                SSLContext sc=SSLContext.getInstance("String_Node_Str");
                sc.init(null,tms_delegate,RandomUtils.SECURE_RANDOM);
                SSLSocketFactory factory=sc.getSocketFactory();
                ssl_con.setSSLSocketFactory(factory);
              }
              if (dh_hack) {
                UrlUtils.DHHackIt(ssl_con);
              }
              if (internal_error_hack && plugin_proxy != null) {
                String host=plugin_proxy.getURLHostRewrite();
                UrlUtils.HTTPSURLConnectionSNIHack(host,ssl_con);
              }
              con=ssl_con;
            }
 else {
              con=(HttpURLConnection)openConnection(force_proxy,url);
            }
            con.setInstanceFollowRedirects(plugin_proxy == null);
            if (plugin_proxy != null) {
              con.setRequestProperty("String_Node_Str",plugin_proxy.getURLHostRewrite() + (initial_url.getPort() == -1 ? "String_Node_Str" : ("String_Node_Str" + initial_url.getPort())));
            }
            con.setRequestMethod("String_Node_Str");
            ClientIDGenerator cidg=ClientIDManagerImpl.getSingleton().getGenerator();
            if (cidg != null) {
              Properties props=new Properties();
              cidg.generateHTTPProperties(null,props);
              String ua=props.getProperty(ClientIDGenerator.PR_USER_AGENT);
              con.setRequestProperty("String_Node_Str",ua);
            }
            setRequestProperties(con,false);
            try {
              con.connect();
            }
 catch (            AEProxyFactory.UnknownHostException e) {
              throw (new UnknownHostException(e.getMessage()));
            }
            int response=con.getResponseCode();
            setProperty("String_Node_Str",new Long(response));
            if ((response != HttpURLConnection.HTTP_ACCEPTED) && (response != HttpURLConnection.HTTP_OK)) {
              if (response == HttpURLConnection.HTTP_MOVED_TEMP || response == HttpURLConnection.HTTP_MOVED_PERM) {
                return (-1);
              }
              URL dest=url;
              if (plugin_proxy != null) {
                try {
                  dest=new URL(plugin_proxy.getTarget());
                }
 catch (                Throwable e) {
                }
              }
              throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(dest) + "String_Node_Str"+ Integer.toString(response)+ "String_Node_Str"+ con.getResponseMessage()));
            }
            getRequestProperties(con);
            ok=true;
            return (UrlUtils.getContentLength(con));
          }
 catch (          SSLException e) {
            String msg=Debug.getNestedExceptionMessage(e);
            if (connect_loop < 3) {
              boolean try_again=false;
              if (msg.contains("String_Node_Str")) {
                if (!dh_hack) {
                  dh_hack=true;
                  try_again=true;
                }
              }
 else               if (msg.contains("String_Node_Str") || msg.contains("String_Node_Str")) {
                if (!internal_error_hack) {
                  internal_error_hack=true;
                  try_again=true;
                }
              }
              ssl_socket_factory=SESecurityManager.installServerCertificates(url);
              if (ssl_socket_factory != null) {
                try_again=true;
              }
              if (try_again) {
                continue;
              }
            }
            throw (e);
          }
catch (          IOException e) {
            if (connect_loop == 0) {
              URL retry_url=UrlUtils.getIPV4Fallback(url);
              if (retry_url != null) {
                url=retry_url;
                continue;
              }
            }
            throw (e);
          }
        }
        throw (new ResourceDownloaderException(this,"String_Node_Str"));
      }
  finally {
        if (auth_supplied) {
          SESecurityManager.setPasswordHandler(url,null);
        }
        if (force_no_proxy) {
          AEProxySelectorFactory.getSelector().endNoProxy();
        }
        if (plugin_proxy != null) {
          plugin_proxy.setOK(ok);
          force_proxy=null;
        }
      }
    }
 catch (    java.net.MalformedURLException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + original_url + "String_Node_Str"+ e.getMessage(),e));
    }
catch (    java.net.UnknownHostException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(original_url) + "String_Node_Str"+ e.getMessage()+ "String_Node_Str",e));
    }
catch (    java.io.IOException e) {
      throw (new ResourceDownloaderException(this,"String_Node_Str" + trimForDisplay(original_url) + "String_Node_Str",e));
    }
  }
 catch (  Throwable e) {
    ResourceDownloaderException rde;
    if (e instanceof ResourceDownloaderException) {
      rde=(ResourceDownloaderException)e;
    }
 else {
      Debug.out(e);
      rde=new ResourceDownloaderException(this,"String_Node_Str",e);
    }
    throw (rde);
  }
}