Skip to content
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6b101df
Added support for the application cache
Mar 25, 2025
95c8383
Fixes to cache REST controller so the same API can be used for any ty…
Mar 30, 2025
a3a0406
Merge branch 'support/4.x' of github.com:craftercms/engine into featu…
Mar 31, 2025
c96e53b
Merge branch 'feature/7860' into support/4.x
Mar 31, 2025
12ccdf2
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Jul 8, 2025
ca67133
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Jul 9, 2025
0f16aed
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Jul 11, 2025
d2777d3
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Aug 5, 2025
7a4c262
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Sep 11, 2025
44d7fb6
Minor enhancements to S3 serverless related classes
Sep 11, 2025
e081bdc
CR recommendations
Sep 11, 2025
f1156d0
CR recommendations
Sep 11, 2025
667f03a
Revert "CR recommendations"
Sep 11, 2025
70e95a1
Fixing S3ContentStoreAdapter
Sep 11, 2025
de252a4
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Sep 11, 2025
f308058
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Sep 18, 2025
fa88a54
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Dec 18, 2025
5ccb09e
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Apr 17, 2026
09345da
Merge branch 'support/4.x' of github.com:craftercms/engine into suppo…
Jun 12, 2026
e12a5ce
Adding code to clear Spring contexts before/after site context init
Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.slf4j.MDC;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig;
import org.tuckey.web.filters.urlrewrite.UrlRewriter;
Expand Down Expand Up @@ -201,11 +203,47 @@ public SiteContext() {
// With this executor maintenance tasks are executed sequentially in the order they're received. This is
// important when a cache warm is submitted and a GraphQL re-build needs to wait till the cache warm is
// finished
maintenanceTaskExecutor = Executors.newSingleThreadExecutor();
maintenanceTaskExecutor = createMaintenanceTaskExecutor();
state = State.INITIALIZING;
initializationLatch = new CountDownLatch(1);
}

private ExecutorService createMaintenanceTaskExecutor() {
ThreadFactory threadFactory = runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setName("site-context-maintenance-" + thread.threadId());
return thread;
};

return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory) {
@Override
protected void beforeExecute(Thread t, Runnable r) {
clearSpringThreadContexts();
super.beforeExecute(t, r);
}

@Override
protected void afterExecute(Runnable r, Throwable t) {
try {
super.afterExecute(r, t);

// Log errors from execute() tasks directly. For submit() tasks, the caller is responsible
// for calling future.get() and handling the exception, so we don't log here to avoid duplicates.
if (t != null) {
logger.error("Error running maintenance task for site '{}'", siteName, t);
}
} finally {
clearSpringThreadContexts();
}
}
};
}

private void clearSpringThreadContexts() {
RequestContextHolder.resetRequestAttributes();
LocaleContextHolder.resetLocaleContext();
}

public ContentStoreService getStoreService() {
return storeService;
}
Expand Down