in src/main/java/org/apache/maven/plugin/doap/DoapUtil.java [469:528]
public static void fetchURL(Settings settings, URL url) throws IOException {
if (url == null) {
throw new IllegalArgumentException("The url is null");
}
if ("file".equals(url.getProtocol())) {
// [ERROR] src/main/java/org/apache/maven/plugin/doap/DoapUtil.java:[474,53] (blocks) EmptyBlock: Empty try
// block.
// Test if file exists
try (InputStream in = url.openStream()) {}
return;
}
// http, https...
HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(DEFAULT_TIMEOUT);
httpClient.getHttpConnectionManager().getParams().setSoTimeout(DEFAULT_TIMEOUT);
httpClient.getParams().setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
// Some web servers don't allow the default user-agent sent by httpClient
httpClient
.getParams()
.setParameter(HttpMethodParams.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
if (settings != null && settings.getActiveProxy() != null) {
Proxy activeProxy = settings.getActiveProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
if (StringUtils.isNotEmpty(activeProxy.getHost())
&& !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost())) {
httpClient.getHostConfiguration().setProxy(activeProxy.getHost(), activeProxy.getPort());
if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
Credentials credentials =
new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
httpClient.getState().setProxyCredentials(AuthScope.ANY, credentials);
}
}
}
GetMethod getMethod = new GetMethod(url.toString());
try {
int status;
try {
status = httpClient.executeMethod(getMethod);
} catch (SocketTimeoutException e) {
// could be a sporadic failure, one more retry before we give up
status = httpClient.executeMethod(getMethod);
}
if (status != HttpStatus.SC_OK) {
throw new FileNotFoundException(url.toString());
}
} finally {
getMethod.releaseConnection();
}
}