You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/09/19 18:58:30 UTC
DO NOT REPLY [Bug 45848] New: AntClassLoader missing a test before
adding a path component
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.
DO NOT REPLY [Bug 45848] AntClassLoader missing a test before adding
a path component
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45848
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |1.8.0
--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2008-09-25 05:34:42 PST ---
it probably shouldn't return right away since addPathFile also scans the
manifest and the jar itself may have been added but not the jars specified in
the manifest.
fixed in svn revision 698947
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 45848] AntClassLoader missing a test before adding
a path component
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45848
--- Comment #2 from Robert Flaherty <ro...@oracle.com> 2008-09-25 07:18:56 PST ---
Sure, I really meant the contains test. So I assume you changed to:
if (pathComponents.contains(file)) {
pathComponents.addElement(pathComponent);
}
Maybe it would be cleaner for the two to be in sync and have addPathComponent
do that also.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.