Buggy code:
class BoundWcsRequest extends WcsReaderRequest { private static final String GET_CAPABILITIES = "GetCapabilities" ; private static final String DESCRIBE_COVERAGE = "DescribeCoverage" ; private static final String GET_COVERAGE = "GetCoverage" ; private static final Map < String , Set < String > > FORMAT_ALIASES ; private static final Log LOG = LogFactory . getLog ( BoundWcsRequest . class . getPackage ( ) . getName ( ) ) ; private static final String XML_ERROR_TYPE = "application//vnd.ogc.se_xml" ; private int bands = - 1 ; private static HashSet < String > set ( String ... values ) { } private final URL _wcsUrl ; private String _describeCoverage ; private String _capabilities ; private Set < String > formats ; private Set < String > responseCrss ; private Set < String > requestCrss ; private Set < String > nativeCRSs ; private HttpClient httpClient = new DefaultHttpClient ( ) ; public void setHttpClient ( HttpClient c ) { } BoundWcsRequest ( URL wcsUrl , WcsReaderRequest request ) { } private BoundWcsRequest ( String version , String coverage , ReferencedEnvelope bbox , CoordinateReferenceSystem responseCRS , double resx , String format , boolean usePost , boolean remoteReproject , boolean useCommandLineGDAL , String username , String password , URL wcsUrl , String capabilities , String describeCoverage ) { } public Set < String > getSupportedFormats ( ) throws IOException { } public Set < String > getSupportedResponseCRSs ( ) throws IOException { } public int numBands ( ) throws IOException { } public Set < String > getSupportedRequestCRSs ( ) throws IOException { } public Set < String > getNativeCRSs ( ) throws IOException { } public String getDescribeCoverage ( ) throws IOException , MalformedURLException , ProtocolException { } public String getCapabilities ( ) throws IOException , MalformedURLException , ProtocolException { } public InputStream getCoverage ( ) throws IOException , MalformedURLException , ProtocolException { } @ Override public BoundWcsRequest withFormat ( String newFormat ) { } @ Override public BoundWcsRequest withCRS ( String code ) { } private Set < String > getUnaliasedFormats ( ) throws IOException { } private String toString ( InputStream stream ) throws IOException { } private InputStream makeRequest ( String request , URL wcsUrl , boolean resolveFormat , int timeout ) throws IOException , MalformedURLException , ProtocolException { httpClient . getParams ( ) . setParameter ( "http.socket.timeout" , new Integer ( timeout ) ) ; httpClient . getParams ( ) . setBooleanParameter ( HANDLE_REDIRECTS , true ) ; ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner ( httpClient . getConnectionManager ( ) . getSchemeRegistry ( ) , ProxySelector . getDefault ( ) ) ; if ( ( httpClient ) instanceof AbstractHttpClient ) { ( ( AbstractHttpClient ) ( httpClient ) ) . setRoutePlanner ( routePlanner ) ; } HttpRequestBase httpRequest ; if ( ( usePost ) && false ) { HttpPost httpPost = new HttpPost ( request ) ; httpRequest = httpPost ; String params = params ( request , "\n" , resolveFormat ) ; BoundWcsRequest . LOG . debug ( ( ( ( ( "making<seq2seq4repair_space>POST<seq2seq4repair_space>request<seq2seq4repair_space>to<seq2seq4repair_space>" + wcsUrl ) + "<seq2seq4repair_space>with<seq2seq4repair_space>post:<seq2seq4repair_space>\n" ) + params ) + "\n\n" ) ) ; HttpEntity bytes = new ByteArrayEntity ( params . getBytes ( ) ) ; httpPost . setEntity ( bytes ) ; } else { String spec = wcsUrl . toExternalForm ( ) ; if ( spec . contains ( "?" ) ) { spec += params ( request , "&" , resolveFormat ) ; } else { spec += "?" + ( params ( request , "&" , resolveFormat ) ) ; } BoundWcsRequest . LOG . info ( ( "making<seq2seq4repair_space>GET<seq2seq4repair_space>request<seq2seq4repair_space>to<seq2seq4repair_space>" + spec ) ) ; httpRequest = new HttpGet ( spec ) ; } BasicHttpContext localcontext = new BasicHttpContext ( ) ; if ( ( username ) != null ) { AuthScope authScope = new AuthScope ( wcsUrl . getHost ( ) , wcsUrl . getPort ( ) ) ; Credentials credentials = new org . apache . http . auth . UsernamePasswordCredentials ( username , password ) ; if ( ( httpClient ) instanceof AbstractHttpClient ) ( ( AbstractHttpClient ) ( httpClient ) ) . getCredentialsProvider ( ) . setCredentials ( authScope , credentials ) ; AuthCache authCache = new BasicAuthCache ( ) ; BasicScheme basicAuth = new BasicScheme ( ) ; <START_BUG> authCache . put ( new HttpHost ( wcsUrl . getHost ( ) , wcsUrl . getPort ( ) ) , basicAuth ) ; <END_BUG> localcontext . setAttribute ( AUTH_CACHE , authCache ) ; ArrayList < String > authpref = new ArrayList < String > ( ) ; authpref . add ( BASIC ) ; authpref . add ( DIGEST ) ; httpClient . getParams ( ) . setParameter ( TARGET_AUTH_PREF , authpref ) ; } HttpResponse response = httpClient . execute ( httpRequest , localcontext ) ; int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; BoundWcsRequest . LOG . debug ( ( "WCS<seq2seq4repair_space>response<seq2seq4repair_space>status<seq2seq4repair_space>:<seq2seq4repair_space>" + statusCode ) ) ; if ( statusCode != 200 ) { throw new ExtractorException ( ( "Error<seq2seq4repair_space>from<seq2seq4repair_space>server<seq2seq4repair_space>while<seq2seq4repair_space>fetching<seq2seq4repair_space>coverage:<seq2seq4repair_space>Response<seq2seq4repair_space>Satus<seq2seq4repair_space>Code<seq2seq4repair_space>not<seq2seq4repair_space>valide<seq2seq4repair_space>-><seq2seq4repair_space>" + statusCode ) ) ; } if ( hasContentType ( response , BoundWcsRequest . XML_ERROR_TYPE ) ) { String error = FileUtils . asString ( response . getEntity ( ) . getContent ( ) ) ; throw new ExtractorException ( ( "Error<seq2seq4repair_space>from<seq2seq4repair_space>server<seq2seq4repair_space>while<seq2seq4repair_space>fetching<seq2seq4repair_space>coverage:" + error ) ) ; } else { return response . getEntity ( ) . getContent ( ) ; } } private boolean hasContentType ( HttpResponse response , String contentType ) { } private String params ( String request , String separator , Boolean resolveFormat ) throws IOException { } private String resolveFormat ( String format ) throws IOException { } private String bboxString ( ) { } private NodeList select ( String xpathExpression , String data ) throws IOException , AssertionError , MalformedURLException , ProtocolException { } public BoundWcsRequest withRequestBBox ( ReferencedEnvelope newBBox ) { } public void assertLegalSize ( long maxSize ) throws IOException { } }

Fix:
authCache . put ( new HttpHost ( wcsUrl . getHost ( ) , wcsUrl . getPort ( ) , wcsUrl . getProtocol ( ) ) , basicAuth ) ;