ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 45848] New: AntClassLoader missing a test before adding a path component
Date Fri, 19 Sep 2008 16:58:30 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=45848

           Summary: AntClassLoader missing a test before adding a path
                    component
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: robert.flaherty@oracle.com


Like addPathComponent():

    public void addPathComponent(File file) {
        if (pathComponents.contains(file)) {
            return;
        }
        pathComponents.addElement(file);
    }

I think addPathFile():

    protected void addPathFile(File pathComponent) throws IOException {
        pathComponents.addElement(pathComponent);
        if (pathComponent.isDirectory()) {
            return;
        }
        ...
    }

should be testing with:

        if (pathComponents.contains(file)) {
            return;
        }

before calling addElement().

This cropped up for me when trying:

                <classloader
classpath="${user.dir}/commons-net-1.4.1.jar;${user.dir}/jakarta-oro-2.0.8.jar;${user.dir}/ant-commons-net.jar"
parentFirst="false" />

which does this in execute():

                acl = new AntClassLoader((ClassLoader) parent,
                         getProject(), classpath, parentFirst);

and then:

            if (classpath != null) {
                String[] list = classpath.list();
                for (int i = 0; i < list.length; i++) {
                    File f = new File(list[i]);
                    if (f.exists()) {
                        acl.addPathElement(f.getAbsolutePath());
                        log("Adding to class loader " +  acl + " " +
f.getAbsolutePath(),
                                Project.MSG_DEBUG);
                    }
                }
            }

adding twice, and yielded debugging:

[classloader] Adding to class loader
AntClassLoader[...\commons-net-1.4.1.jar;...\jakarta-oro-2.0.8.jar;...\ant-commons-net.jar;...\commons-net-1.4.1.jar]
...\commons-net-1.4.1.jar
[classloader] Adding to class loader
AntClassLoader[...\commons-net-1.4.1.jar;...\jakarta-oro-2.0.8.jar;...\ant-commons-net.jar;...\commons-net-1.4.1.jar;...\jakarta-oro-2.0.8.jar]
...\jakarta-oro-2.0.8.jar
[classloader] Adding to class loader
AntClassLoader[...\commons-net-1.4.1.jar;...\jakarta-oro-2.0.8.jar;...\ant-commons-net.jar;...\commons-net-1.4.1.jar;...\jakarta-oro-2.0.8.jar;...\ant-commons-net.jar]
...\ant-commons-net.jar

The test will prevent any duplicates.  I'll enter a separate defect for
Classloader for the duplicate add calls.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message