ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Pfeiffer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IVY-1464) Inconsistency between local and remote <properties>
Date Thu, 20 Mar 2014 14:04:43 GMT

    [ https://issues.apache.org/jira/browse/IVY-1464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13941753#comment-13941753
] 

Carsten Pfeiffer commented on IVY-1464:
---------------------------------------

Some reasoning for this: repository browsers like viewvc or gitblit return 404 when requesting
an inexisting file. If you reference an {{ivysettings.xml}} directly from a repository provider
you get an error when some referenced properties file does not exist in the repository. If
you would reference the same file in your local checkout you would get just a warning.

> 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
>              Labels: patch
>         Attachments: not-found.patch
>
>
> 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)

Mime
View raw message