Skip to content

WW-5831 fix(xslt): make BeanAdapter property descriptor cache thread-safe - #2089

Open
g0w6y wants to merge 1 commit into
apache:mainfrom
g0w6y:WW-5831-xslt-beanadapter-cache
Open

g0w6y wants to merge 1 commit into
apache:mainfrom
g0w6y:WW-5831-xslt-beanadapter-cache

Conversation

@g0w6y

@g0w6y g0w6y commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes WW-5831

Hardening, no behaviour change. BeanAdapter.propertyDescriptorCache is a static, lazily created HashMap guarded by a synchronized instance method. Each render creates its own BeanAdapter, so the lock is never shared. It is now a static final ConcurrentHashMap, and the lazy-init block and synchronized are removed. Same approach as WW-5647 (#1781) for XSLTResult.templatesCache.

BeanAdapterTest#testConcurrentAdaptersCacheEachBeanClassOnce has 16 threads fetch descriptors for 4,095 distinct bean classes and asserts exactly 4,095 entries were added. Without the change it failed 28/28 runs, with the cache size above the class count by a varying amount (observed 4100 to 4114 in 28 runs; it varies per run). With the change it passed 20/20.

The test is statistical: it can pass without the fix on a fast machine (an earlier 500-class variant did in some runs), but it never fails with the fix. The classes are java.lang.reflect.Proxy classes over every non-empty subset of 12 JDK interfaces, all in the test class loader, so no class loaders are created.

Not changed: no bound is added to the cache. Not claiming a security issue or data exposure; only the corrupted map size was measured. The matching ScopeInterceptor change is #2082.

xslt plugin module on the rebased branch (clean build): 18 tests, 0 failures. With only the production change reverted, BeanAdapterTest fails.

…safe

The static cache was a lazily created HashMap guarded by a synchronized
instance method, so concurrent renders did not share the lock. It is now
a static final ConcurrentHashMap, as in WW-5647 for XSLTResult.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant