You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Carsten Pfeiffer (JIRA)" <ji...@apache.org> on 2014/03/20 14:56:46 UTC
[jira] [Created] (IVY-1464) Inconsistency between local and remote
Carsten Pfeiffer created IVY-1464:
-------------------------------------
Summary: Inconsistency between local and remote <properties>
Key: IVY-1464
URL: https://issues.apache.org/jira/browse/IVY-1464
Project: Ivy
Issue Type: Bug
Components: Core
Affects Versions: 2.3.0
Reporter: Carsten Pfeiffer
Priority: Minor
When using a {{<properties>}} element in an {{ivysettings.xml}} ivy behaves differently when the referenced properties file does not exist.
In case the properties file is local, a {{FileNotFoundException}} is caught and only a warning is logged (i.e. non-fatal).
In case the file is remote, only a generic {{IOException}} occurs, which fails the build.
Not sure how to best fix this. One fix would be like this:
{code}
try {
URL fileUrl = urlFromFileAttribute(propFilePath);
try {
ivy.loadProperties(fileUrl, override);
} catch (FileNotFoundException ex) {
throw ex;
} catch (IOException ex) {
try {
URLConnection connection = fileUrl.openConnection();
if (connection instanceof HttpURLConnection) {
int code = ((HttpURLConnection) connection).getResponseCode();
if (code == 404) {
// file does not exist, just log a warning like in the local file
// case
Message.verbose("Unable to download property file (404 not found): "
+ propFilePath);
return;
}
}
} catch (Exception e) {
// ignore all follow up errors and throw the original exception instead
}
throw ex;
}
} catch (FileNotFoundException e) {
Message.verbose("Unable to find property file: " + propFilePath);
}
{code}
If you want to spare the second attempt to download the file when the exception occurs, you would have to refactor {{IvySettings.loadProperties()}} a bit.
--
This message was sent by Atlassian JIRA
(v6.2#6252)