[
https://issues.apache.org/jira/browse/FELIX-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673270#action_12673270
]
rickhall edited comment on FELIX-934 at 2/13/09 7:26 AM:
----------------------------------------------------------------
You are right, my fix is not complete, but your suggestion is also not correct.
See? It isn't so easy. ;-)
Your fix will not match package "foo" against "foo.*", since it will compare
"foo" to "foo.", which is the case my original patch is trying to get. The
mistake I made, is that we only want to do the regionMatches() if the package
names are the same length, otherwise we get the bug you discovered (i.e., my
original fix matches "foo" with "foo.", but also "foop" with "foo.").
So, the actual fix should be:
if ((m_bootPkgWildcards[i] &&
(pkgName.startsWith(m_bootPkgs[i]) ||
((pkgName.length() == m_bootPkgs[i].length() - 1) &&
pkgName.regionMatches(0, m_bootPkgs[i], 0,
m_bootPkgs[i].length() - 1))))
|| (!m_bootPkgWildcards[i] &&
m_bootPkgs[i].equals(pkgName)))
You can see here that we only do the regionMatches() if the two package names
are the same length (ignoring the dot). Whew!
Thanks for double checking this...feel free to triple check! :-)
was (Author: rickhall):
You are right, my fix is not complete, but your suggestion is also not
correct. See? It isn't so easy. ;-)
Your fix will not match package "foo" against "foo.*", since it will compare
"foo" to "foo.", which is which is the case my original patch is trying to get.
The mistake I made, is that we only want to do the regionMatches() if the
package names are the same length, otherwise we get the bug you discovered
(i.e., my original fix matches "foo" with "foo.", but also "foop" with "foo.").
So, the actual fix should be:
if ((m_bootPkgWildcards[i] &&
(pkgName.startsWith(m_bootPkgs[i]) ||
((pkgName.length() == m_bootPkgs[i].length() - 1) &&
pkgName.regionMatches(0, m_bootPkgs[i], 0,
m_bootPkgs[i].length() - 1))))
|| (!m_bootPkgWildcards[i] &&
m_bootPkgs[i].equals(pkgName)))
You can see here that we only do the regionMatches() if the two package names
are the same length (ignoring the dot). Whew!
Thanks for double checking this...feel free to triple check! :-)
> Bootdelegation bug
> ------------------
>
> Key: FELIX-934
> URL: https://issues.apache.org/jira/browse/FELIX-934
> Project: Felix
> Issue Type: Bug
> Components: Framework
> Affects Versions: felix-1.4.1
> Environment: All
> Reporter: Robert Koszegi
> Assignee: Richard S. Hall
> Fix For: felix-1.6.0
>
>
> Bootdelegation does not work as supposed in 1.4.1
> Let's say I provide the following parameter at startup
> org.osgi.framework.bootdelegation=org.acme.foo.bar.*
> Then the class org.acme.foo.bar.ClassA should be loaded by the boot
> classloader meanwhile org.acme.foo.ClassB should not, however currently both
> classes will be loaded by the boot classloader.
> This is due to a bug in R4SearchPolicyCore with checking if the
> bootdelegation should be applied for a given package:
> if ((m_bootPkgWildcards[i] &&
> (pkgName.startsWith(m_bootPkgs[i]) ||
> m_bootPkgs[i].regionMatches(0, pkgName, 0,
> pkgName.length())))
> || (!m_bootPkgWildcards[i] &&
> m_bootPkgs[i].equals(pkgName)))
> That is m_bootPkgs[i].regionMatches(0, pkgName, 0, pkgName.length()) will
> pass for org.acme.foo if the bootdelegation is set for org.acme.foo.bar.* -
> but it should not!
> Regards,
> Robert
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.