This problem doesn't reproduce every time. In fact, it's less likely to reproduce than reproducing it. When the problem occurred, the HttpSendRequest in CDownloadDialog::DownloadFile returns an error code of 12029 (ERROR_INTERNET_CANNOT_CONNECT) while trying to download http://java.sun.com/webapps/download/AutoDL?BundleId=36668 which in turns download the JRE iftw bundle. Adding some retry logic when encountering ERROR_INTERNET_CANNOT_CONNECT seems to have fixed the problem.
Also including some cleanup in this fix:
- use windows error code instead of defining our own;
- local variable name, szURL, is in conflict with the input parameter name.