Buggy code:
public class WcsExtractor { private final File _basedir ; private final WcsFormat _format ; private RequestConfiguration requestConfig ; public WcsExtractor ( File requestBaseDir , RequestConfiguration requestConfig ) { } protected static final Log LOG = LogFactory . getLog ( WcsExtractor . class . getPackage ( ) . getName ( ) ) ; public void checkPermission ( ExtractorLayerRequest request , String secureHost , String username , String roles ) throws IOException , MalformedURLException { URL capabilitiesURL = request . capabilitiesURL ( "WMS" , null ) ; final HttpClientBuilder httpClientBuilder = HttpClientBuilder . create ( ) ; HttpClientContext localContext = HttpClientContext . create ( ) ; <START_BUG> final HttpHost httpHost = new HttpHost ( capabilitiesURL . getHost ( ) , capabilitiesURL . getPort ( ) ) ; <END_BUG> HttpGet get = new HttpGet ( capabilitiesURL . toExternalForm ( ) ) ; if ( ( username != null ) && ( ( ( secureHost . equalsIgnoreCase ( request . _url . getHost ( ) ) ) || ( "127.0.0.1" . equalsIgnoreCase ( request . _url . getHost ( ) ) ) ) || ( "localhost" . equalsIgnoreCase ( request . _url . getHost ( ) ) ) ) ) { WcsExtractor . LOG . debug ( ( ( ( getClass ( ) . getSimpleName ( ) ) + ".checkPermission<seq2seq4repair_space>-<seq2seq4repair_space>Secured<seq2seq4repair_space>Server:<seq2seq4repair_space>adding<seq2seq4repair_space>username<seq2seq4repair_space>header<seq2seq4repair_space>and<seq2seq4repair_space>role<seq2seq4repair_space>headers<seq2seq4repair_space>to<seq2seq4repair_space>" ) + "request<seq2seq4repair_space>for<seq2seq4repair_space>checkPermission" ) ) ; WfsExtractor . addImpersonateUserHeaders ( username , roles , get ) ; String extractorAppUsername = requestConfig . adminCredentials . getUserName ( ) ; String extractorAppPassword = requestConfig . adminCredentials . getPassword ( ) ; WfsExtractor . enablePreemptiveBasicAuth ( capabilitiesURL , httpClientBuilder , localContext , httpHost , extractorAppUsername , extractorAppPassword ) ; } else { WcsExtractor . LOG . debug ( ( ( getClass ( ) . getSimpleName ( ) ) + "checkPermission<seq2seq4repair_space>-<seq2seq4repair_space>Non<seq2seq4repair_space>Secured<seq2seq4repair_space>Server" ) ) ; } final CloseableHttpClient httpclient = httpClientBuilder . build ( ) ; String capabilities = FileUtils . asString ( httpclient . execute ( httpHost , get , localContext ) . getEntity ( ) . getContent ( ) ) ; Pattern regex = Pattern . compile ( ( ( "(?m)<Layer[^>]*>(\\\\n|\\s)*<Name>\\s*(\\w*:)?" + ( Pattern . quote ( request . _layerName ) ) ) + "\\s*<//Name>" ) ) ; boolean permitted = regex . matcher ( capabilities ) . find ( ) ; if ( ! permitted ) { throw new SecurityException ( ( ( ( ( "User<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>have<seq2seq4repair_space>sufficient<seq2seq4repair_space>privileges<seq2seq4repair_space>to<seq2seq4repair_space>access<seq2seq4repair_space>the<seq2seq4repair_space>Layer:<seq2seq4repair_space>" + ( request . _layerName ) ) + ".<seq2seq4repair_space>" ) + "\n\nCapabilties:<seq2seq4repair_space>" ) + capabilities ) ) ; } } public File extract ( ExtractorLayerRequest request ) throws IOException , FactoryException , TransformException { } }

Fix:
final HttpHost httpHost = new HttpHost ( capabilitiesURL . getHost ( ) , capabilitiesURL . getPort ( ) , capabilitiesURL . getProtocol ( ) ) ;