czw., 19 gru 2024 o 21:42 Florian Schlittgen <schlitt...@liwa.de> napisaĆ(a): > > You're right, the package is supposed to be excluded. So I started > debugging and tracked it down to the > org.apache.struts2.util.WildcardHelper. There seems to be an issue, as > you can see in this example: > > public static void main(String[] args) { > String packageExclude = "org.apache.struts2.*"; > String classPackageName = "org.apache.struts2"; > > WildcardHelper wildcardHelper = new WildcardHelper(); > int[] packagePattern = > wildcardHelper.compilePattern(packageExclude); > System.out.println(wildcardHelper.match(new HashMap<>(), > classPackageName, packagePattern)); > } > > The output is 'false', so the pattern "org.apache.struts2.*" does not > match with the package "org.apache.struts2". > Maybe you'll know immediately what the problem is. Otherwise, I can take > another look and find the error in the match method... just let me know.
It doesn't match because there is no ".", this works: public static void main(String[] args) { String packageExclude = "org.apache.struts2.*"; String classPackageName = "org.apache.struts2."; WildcardHelper wildcardHelper = new WildcardHelper(); int[] packagePattern = wildcardHelper.compilePattern(packageExclude); System.out.println(wildcardHelper.match(new HashMap<>(), classPackageName, packagePattern)); } also this works public void testMatchStrutsPackages() { // given HashMap<String, String> matchedPatterns = new HashMap<>(); int[] pattern = wildcardHelper.compilePattern("org.apache.struts2.*"); // when & then assertTrue(wildcardHelper.match(matchedPatterns, "org.apache.struts2.XWorkTestCase", pattern)); assertEquals("org.apache.struts2.XWorkTestCase", matchedPatterns.get("0")); assertEquals("XWorkTestCase", matchedPatterns.get("1")); assertTrue(wildcardHelper.match(matchedPatterns, "org.apache.struts2.core.SomeClass", pattern)); assertEquals("org.apache.struts2.core.SomeClass", matchedPatterns.get("0")); assertEquals("core.SomeClass", matchedPatterns.get("1")); } It must be something else Cheers Lukasz --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org For additional commands, e-mail: dev-h...@struts.apache.org