On 23.12.24 19:12, Lukasz Lenart wrote:
Thanks for looking into it. Your examples/tests are alright, but I think this is not the way it is being called. Please take a look at org.apache.struts2.convention.PackageBasedActionConfigBuilder.includeClassNameInActionScan(String). While debugging I can see that this method is being called with parameter "className" = "org.apache.struts2.XWorkTestCase". In the method's first line the package name is derived from the className by using "StringUtils.substringBeforeLast(className, ".")" which gives you "org.apache.struts2", no trailing dot. And without trailing dot it is not working.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")); }
Could you check whether it is the same for you? Thanks! Cheers, Florian
smime.p7s
Description: S/MIME Cryptographic Signature