Hi, Jeff. It does look like it would be nice for FileResource's (File)
constructors to set basedir. I'm looking into this.
Matt
On Thu, Feb 9, 2012 at 4:19 PM, Jeffrey E Care <carej@us.ibm.com> wrote:
> I was trying to track down some strange behavior in one of our custom
> resource collections and I think that I might have stumbled across a
> potential but in ResourceUtils. Specifically, in the "asFileResource"
> method:
>
> /**
> * Convenience method to turn any fileProvider into a basic
> * FileResource with the file's immediate parent as the basedir,
> * for tasks that need one.
> * @param fileProvider input
> * @return fileProvider if it is a FileResource instance, or a new
> * FileResource with fileProvider's file.
> * @since Ant 1.8
> */
> public static FileResource asFileResource(FileProvider fileProvider) {
> if (fileProvider instanceof FileResource || fileProvider == null) {
> return (FileResource) fileProvider;
> }
> FileResource result = new FileResource(fileProvider.getFile());
> result.setProject(Project.getProject(fileProvider));
> return result;
> }
>
> This method purports to return a FileResource whose baseDir will be the
> parent of the file returned by the passed FileProvider. The only problem is
> that setBaseDir is never called on the new'ed up FileResource from this
> code path. Also, in the instanceof case there's no promise that the
> FileProvider cast to FileResource has a non-null basedir either.
>
> The fix for my collection was simply to set the basedir on all of its
> resources. I think the real fix here might be that the FileResource(File)
> constructor should also set the basedir on the FileResource to the passed
> File's parent? I'm not sure the best way to fix this but I think that
> something is clearly not right.
> ____________________________________________________________________________________________
> Jeffrey E. (Jeff) Care
> *carej@us.ibm.com* <carej@us.ibm.com>
> IBM WebSphere Application Server
> WAS Release Engineering
>
> [image: WebSphere Mosiac]
> [image: WebSphere Brandmark]
>
>
|