Skip to content

Commit 6fe93c4

Browse files
authored
chore: improve class scanning filter (#20978)
Ignores additional well known packages when scanning classes to find frontend resources.
1 parent c8811e5 commit 6fe93c4

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FrontendDependencies.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@
7777
public class FrontendDependencies extends AbstractDependenciesScanner {
7878

7979
//@formatter:off
80-
private static final Pattern VISITABLE_CLASS_PATTERN = Pattern.compile("(^$|"
80+
private static final Pattern NOT_VISITABLE_CLASS_PATTERN = Pattern.compile("(^$|"
8181
+ ".*(slf4j).*|"
8282
// #5803
83-
+ "^(java|sun|oracle|elemental|javax|jakarta|oshi|"
84-
+ "org\\.(apache|atmosphere|jsoup|jboss|w3c|spring|joda|hibernate|glassfish|hsqldb|osgi|jooq)\\b|"
85-
+ "com\\.(helger|spring|gwt|lowagie|fasterxml|sun|nimbusds|googlecode)\\b|"
83+
+ "^(java|sun|oracle|elemental|javax|javafx|jakarta|oshi|cglib|"
84+
+ "org\\.(apache|antlr|atmosphere|aspectj|jsoup|jboss|w3c|spring|joda|hibernate|glassfish|hsqldb|osgi|jooq|springframework|bouncycastle|snakeyaml|keycloak|flywaydb)\\b|"
85+
+ "com\\.(helger|spring|gwt|lowagie|fasterxml|sun|nimbusds|googlecode|ibm)\\b|"
86+
+ "ch\\.quos\\.logback\\b|"
87+
+ "io\\.(fabric8\\.kubernetes)\\b|"
8688
+ "net\\.(sf|bytebuddy)\\b"
8789
+ ").*|"
8890
+ ".*(Exception)$"
@@ -903,7 +905,7 @@ protected boolean shouldVisit(String className) {
903905
// common name-spaces that would not have components.
904906
// We also exclude Feature-Flag classes
905907
return className != null && !isExperimental(className)
906-
&& !VISITABLE_CLASS_PATTERN.matcher(className).matches();
908+
&& !NOT_VISITABLE_CLASS_PATTERN.matcher(className).matches();
907909
}
908910

909911
private URL getUrl(String className) {

flow-server/src/test/java/com/vaadin/flow/server/frontend/scanner/FrontendDependenciesTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ public void shouldVisit_shouldNotMatchOnPartOfPackage() {
327327
classFinder, true);
328328

329329
Assert.assertTrue(
330-
"second package should match fully not as starts with 'spring != springframework'",
331-
dependencies.shouldVisit("org.springframework.samples"));
330+
"second package should match fully not as starts with 'spring != springseason'",
331+
dependencies.shouldVisit("org.springseason.samples"));
332332
Assert.assertTrue(
333-
"second package should match fully not as starts with 'spring != springframework'",
334-
dependencies.shouldVisit("org.springframework"));
333+
"second package should match fully not as starts with 'spring != springseason'",
334+
dependencies.shouldVisit("org.springseason"));
335335
Assert.assertFalse("should not visit with only 2 packages 'org.spring'",
336336
dependencies.shouldVisit("org.spring"));
337337

0 commit comments

Comments
 (0)