private void jenkins48775workaround ( Proxy proxy , URL url ) { if ( "https" . equals ( url . getProtocol ( ) ) && ! authCacheSeeded && proxy != Proxy . NO_PROXY ) { HttpURLConnection preAuth = null ; try { // We do not care if there is anything at this URL, all we care is that it is using the proxy preAuth = ( HttpURLConnection ) new URL ( "http" , url . getHost ( ) , - 1 , "/" ) . openConnection ( proxy ) ; preAuth . setRequestMethod ( "HEAD" ) ; preAuth . connect ( ) ; } catch ( IOException e ) { // ignore, this is just a probe we don't care at all } finally { if ( preAuth != null ) { preAuth . disconnect ( ) ; } } authCacheSeeded = true ; } else if ( "https" . equals ( url . getProtocol ( ) ) ) { // if we access any http url using a proxy then the auth cache will have been seeded authCacheSeeded = authCacheSeeded || proxy != Proxy . NO_PROXY ; } }
If the first URL we try to access with a HTTP proxy is HTTPS then the authentication cache will not have been pre - populated so we try to access at least one HTTP URL before the very first HTTPS url .