maintenance portlet | Implement Cache Management Apis #35190#35218
maintenance portlet | Implement Cache Management Apis #35190#35218hassandotcms wants to merge 5 commits intomainfrom
Conversation
|
Claude finished @hassandotcms's task in 1m 56s —— View job PR Review: Cache Management APIs #35190
Fixed since last review: Issues1.
2. Race condition on
Fix: initialize in the constructor, or add 3.
4.
5. Integration tests still bypass HTTP layer
Minor
|
|
Claude finished @hassandotcms's task in 1m 35s —— View job PR Review: Cache Management APIs #35190
Issues Found1.
2. Race condition on
Fix: initialize 3.
4.
DotInitializer.class.cast(APILocator.getPublisherAPI()).init();This casts the publisher API to 5. The modified 6.
7.
8. Integration tests bypass HTTP layer entirely The tests call Java methods directly on Minor
|
Rollback Safety Analysis
Verdict: Safe to Rollback All 8 changed files were checked against every category in the rollback-unsafe reference:
Why this is safe: All changes are purely additive — new Java classes, new REST endpoints, new Swagger docs, and a new integration test. No database schema is altered, no data is transformed, and the one modified endpoint keeps its existing HTTP contract. Rolling back to N-1 simply removes the three new endpoints; nothing N wrote to storage would be unreadable by N-1. Label applied: |
0787c76 to
adc7ad7
Compare
dotCMS/src/main/java/com/dotcms/rest/api/v1/system/cache/CacheResource.java
Show resolved
Hide resolved
Add 3 new endpoints to CacheResource and fix missing side effects on the
existing flush-all endpoint to support the modernized Maintenance portlet
Cache tab.
New endpoints:
- GET /api/v1/caches — list cache region names (sorted)
- GET /api/v1/caches/stats — JVM memory + per-provider cache statistics
- DELETE /api/v1/caches/region/{regionName} — flush specific region or all
Modified:
- DELETE /api/v1/caches/provider/{p}/flush — add resetAllPermissionReferences
and PushPublishing filter reload that were missing vs legacy Struts action
Shared flush logic extracted to CacheMaintenanceHelper. Typed immutable
views (JvmMemoryView, CacheProviderStatsView, CacheStatsView) with full
Swagger/OpenAPI annotations. Integration tests for all endpoints.
Closes #35196, Closes #35197, Closes #35198
Remove unused public getValidRegionNames() from CacheMaintenanceHelper — dead code with no callers. Rename test to match what it actually verifies.
- Remove dead @ApplicationScoped from CacheMaintenanceHelper (CDI never
managed it)
- Wrap DotInitializer cast in try-catch to prevent ClassCastException
from aborting flush response
- Make region name lookup case-insensitive via resolveRegionName();
"permission" now resolves to canonical "Permission"
- Add .* regex to {regionName} path param for consistency with existing
endpoints
- Add test for case-insensitive region resolution
- Add @Operation/@ApiResponses to flushAll() documenting behavior change (permission reset + PushPublishing reload) and that provider param is ignored - Change freeMemory assertion from > 0 to >= 0 to prevent flaky failures under CI memory pressure
In a clustered environment, cache stats are per-node. Without node identity, the caller has no way to know which node reported the stats. Add clusterId (shared across cluster), serverId (unique per node), and serverName (hostname) to the GET /api/v1/caches/stats response. Uses InetAddress.getLocalHost() directly to avoid a DB call on every request.
ca0af66 to
2082ae4
Compare
Summary
Add 3 new REST endpoints to
CacheResourceand fix missing side effects on the existing flush-all endpoint, replacing legacy JSP/Struts cache management with modern REST APIs for the Maintenance portletCache tab.
New endpoints:
GET /api/v1/caches— Alphabetically sorted list of cache region names (replaces JSP scriptlet callingCacheLocator.getCacheIndexes())GET /api/v1/caches/stats— JVM memory stats + per-provider per-region cache statistics (replacescachestats_guava.jsp)DELETE /api/v1/caches/region/{regionName}— Flush a specific cache region across all providers, or pass"all"to flush everything. Includes permission reference reset and conditional PushPublishingfilter reload
Bug fix:
DELETE /api/v1/caches/provider/{p}/flush— AddedresetAllPermissionReferences()+ PushPublishing filter reload that were missing vs the legacy Struts action (ViewCMSMaintenanceAction._flush())Implementation details:
CacheMaintenanceHelper(@ApplicationScoped) extracts shared flush side-effect logic used by both the new and existing flush endpoints@Value.Immutableviews (JvmMemoryView,CacheProviderStatsView,CacheStatsView) with full Swagger/OpenAPI annotationsCacheIndex— unknown names return 400 instead of silently flushing all caches (legacy NPE-catching behavior)/region/path prefix avoids JAX-RS conflict with existingDELETE /api/v1/caches/menucacheTest plan
./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dit.test=CacheResourceIntegrationTestGET /api/v1/cachesreturns sorted region list matching the Cache tab dropdownGET /api/v1/caches/statsreturns memory + provider stats matchingcachestats_guava.jspoutputDELETE /api/v1/caches/region/Permissionflushes Permission cache and returns 200DELETE /api/v1/caches/region/allflushes all caches and returns 200DELETE /api/v1/caches/region/InvalidNamereturns 400DELETE /api/v1/caches/region/Systemtriggers PushPublishing filter reloadDELETE /api/v1/caches/provider/{p}/flushstill returns 200 with "flushed all"CacheResource.postman_collection.jsonpasses unchangedCloses #35196, Closes #35197, Closes #35198