Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching: Cache all com.vaadin.flow class instances #17644

Merged
merged 9 commits into from
Sep 21, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ public void testDevModeClassCachePopulated() {

for (int i = 1; i < 6; i++) {
String[] value = allSpans.get(i).getText().split(":");
Assert.assertTrue("Expected " + value[0] + " to be greater than 0.",
Integer.parseInt(value[1]) > 0);
if ("dynamic white list count".equals(value[0])) {
Assert.assertTrue("Expected " + value[0] + " to be 0.",
Integer.parseInt(value[1]) == 0);
} else {
Assert.assertTrue(
"Expected " + value[0] + " to be greater than 0.",
Integer.parseInt(value[1]) > 0);
}
}

Assert.assertEquals("Unexpected cached route packages.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ class ReloadCache implements Serializable {
static Set<String> skippedResources = new HashSet<>();
static Set<String> dynamicWhiteList;
static Set<String> routePackages;
static Set<Class<?>> vaadinClasses = new HashSet<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,15 @@ public void failFastContextInitialized(ServletContextEvent event)
.collect(Collectors.toSet());

if (devModeCachingEnabled) {
classes.addAll(ReloadCache.vaadinClasses);
ReloadCache.dynamicWhiteList = classes.stream()
.map(Class::getPackageName).collect(Collectors.toSet());
.map(Class::getPackageName)
.filter(packageName -> !packageName
.startsWith("com.vaadin.flow"))
.collect(Collectors.toSet());
ReloadCache.vaadinClasses = classes.stream().filter(
c -> c.getPackageName().startsWith("com.vaadin.flow"))
tepi marked this conversation as resolved.
Show resolved Hide resolved
tepi marked this conversation as resolved.
Show resolved Hide resolved
.collect(Collectors.toSet());
}

long ms = (System.nanoTime() - start) / 1000000;
Expand Down
Loading