Repository navigation
Cache installed applications once, unmodifiable, in AbstractOperatingSystem - #3898
Conversation
…System Every platform memoized getInstalledApplications() itself, and Linux, AIX and Windows (JNA and FFM) handed out the cached ArrayList, so a caller that filtered or cleared it changed what every later caller saw until the cache expired. AbstractOperatingSystem now owns the cache and wraps it in an unmodifiable list behind a final getter; each platform overrides only queryInstalledApps(), which defaults to an empty list. A caller that modified the returned list now gets UnsupportedOperationException, as on macOS.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Follow-up to #3895's review: centralize the installed-applications cache.
Changes
getInstalledApplications()itself. Linux, AIX and Windows (JNA and FFM) returned the cachedArrayListdirectly, so a caller that filtered or cleared it changed what every later caller saw until the cache expired. macOS, the BSDs and Solaris already cached an unmodifiable list.AbstractOperatingSystemnow owns the cache (installedAppsExpiration()) and wraps the result withCollections.unmodifiableList. ItsgetInstalledApplications()isfinal, so a platform cannot bypass the cache.protected List<ApplicationInfo> queryInstalledApps(), which defaults to an empty list. The per-platform supplier fields and getters are removed from Linux, macOS, AIX, Solaris, the BSD base, and both Windows backends.Behavior: on Linux, AIX and Windows, modifying the returned list now throws
UnsupportedOperationException. The returned list was never meant to be mutable, so this has no CHANGELOG entry.Verification
AbstractOperatingSystemTestcover the default empty list, unmodifiability, and that the list is queried once while cached.-Perror-prone -Paggregate-coverageand tests: all modules pass, comparison tests included.Summary by CodeRabbit