Skip to content

Comments

WW-5514: Make ProxyUtil cache configurable via struts constants#1573

Merged
lukaszlenart merged 2 commits intorelease/struts-6-8-xfrom
fix/WW-5514-proxy-cache-configurable
Feb 21, 2026
Merged

WW-5514: Make ProxyUtil cache configurable via struts constants#1573
lukaszlenart merged 2 commits intorelease/struts-6-8-xfrom
fix/WW-5514-proxy-cache-configurable

Conversation

@lukaszlenart
Copy link
Member

@lukaszlenart lukaszlenart commented Feb 9, 2026

Summary

Makes the ProxyUtil cache type configurable through Struts constants, allowing applications to use BASIC cache type (default) without requiring Caffeine as a mandatory dependency.

Fixes WW-5514

Key Changes

  • ProxyCacheFactory interface - marker interface for DI extending OgnlCacheFactory
  • StrutsProxyCacheFactory - implementation with @Inject constructor reading from struts constants
  • StrutsProxyCacheFactoryBean - wiring bean that sets the factory on ProxyUtil during container initialization
  • ProxyUtil - converted from static initialization to lazy initialization with factory injection
  • Configuration constants for proxy cache type and size

Configuration

New properties in default.properties:

# Default (no Caffeine required)
struts.proxy.cacheType=basic
struts.proxy.cacheMaxSize=10000

# High-performance option (requires Caffeine)
struts.proxy.cacheType=wtlfu

# LRU option (no Caffeine required)  
struts.proxy.cacheType=lru

Comparison with Struts 7.x approach (PR #1572)

This is a minimal/conservative fix for 6.x that:

  • Keeps ProxyUtil as a static utility (higher backward compatibility)
  • Adds lazy initialization + configurable cache factory
  • Does not modify interceptors or SecurityMemberAccess

The Struts 7.x PR #1572 takes a more comprehensive approach with a full ProxyService abstraction.

Test Plan

  • Core module tests pass (2664 tests)
  • Spring plugin tests pass (67 tests, including SpringProxyUtilTest)
  • Manual testing with Spring AOP proxied actions

🤖 Generated with Claude Code

Makes the ProxyUtil cache type configurable through Struts constants,
allowing applications to use BASIC cache type (default) without
requiring Caffeine as a mandatory dependency.

New configuration properties:
- struts.proxy.cacheType: basic (default), lru, or wtlfu
- struts.proxy.cacheMaxSize: 10000 (default)

Fixes WW-5514

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the fix/WW-5514-proxy-cache-configurable branch from 6eee2f7 to bbc2afc Compare February 20, 2026 07:10
@lukaszlenart lukaszlenart marked this pull request as ready for review February 20, 2026 07:11
Copy link
Member

@kusalk kusalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One initialisation race I'm concerned about, other than that looks good!

Extract lazy initialization into reusable LazyRef<T> utility with
double-checked locking and reset support. ProxyUtil.setProxyCacheFactory()
now resets both caches so they are recreated with the new factory,
fixing the bug where caches were never refreshed after factory changes.
Default proxy cache type changed from 'basic' to 'wtlfu' for consistency
with expression and beanInfo caches. Fix @SInCE version to 6.9.0.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
22 Security Hotspots
42.4% Coverage on New Code (required ≥ 80%)
3.4% Duplication on New Code (required ≤ 3%)
E Reliability Rating on New Code (required ≥ A)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lukaszlenart lukaszlenart requested a review from kusalk February 21, 2026 08:53
/**
* Invalidates the cached value so the next {@link #get()} call recomputes it.
*/
public void reset() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should technically be synchronized but anyway it's a super edge case so I wouldn't worry

@lukaszlenart lukaszlenart merged commit 18d6e77 into release/struts-6-8-x Feb 21, 2026
6 of 14 checks passed
@lukaszlenart lukaszlenart deleted the fix/WW-5514-proxy-cache-configurable branch February 21, 2026 17:17
@lukaszlenart lukaszlenart added this to the 6.9.0 milestone Feb 21, 2026
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.

2 participants