Skip to content

Modernize ControlRegistry.java — 6 Tasks #25

Description

@gilbertoca

Tasks for ControlRegistry.java:

  • Convert InterceptorHolder to record (refat)

    • Description: Eliminates hand-written getters, setters, equals, and hashCode. The compiler generates everything with correct immutable semantics. Reduces JAR bytecode.
    • Location: InterceptorHolder (line ~460)
    • Effort: Minimum
  • Replace RegistryStack (extends ArrayList) with ArrayDeque (medium)

    • Description: Inheriting from ArrayList exposes unnecessary public API and is an anti-pattern in JDK 17. ArrayDeque is the correct and more efficient implementation for stacks.
    • Location: RegistryStack (line ~410)
    • Effort: Low
  • Switch ThreadLocal.set(null) to ThreadLocal.remove() (low)

    • Description: set(null) does not remove the entry from the server thread pool (Tomcat/Jetty). remove() is the correct way to avoid memory leaks in environments with thread reuse.
    • Location: popThreadLocalRegistry (line ~385)
    • Effort: Minimum
  • Evaluate LinkedHashSet -> HashSet for ajaxTargetControls (low)

    • Description: LinkedHashSet maintains insertion order with extra memory cost. Check if order is semantically necessary; if not, HashSet reduces overhead.
    • Location: getAjaxTargetControls (line ~330)
    • Effort: Minimum
  • Remove lazy null-check in getAjaxTargetControls and getInterceptors (low)

    • Description: Initializing collections in the constructor with a small initial capacity (2–4) eliminates repeated checks per request without significant memory cost.
    • Location: constructor + getters (lines ~320–345)
    • Effort: Minimum
  • Consolidate processPreResponse / PreRenderHead / PreDestroy (refat)

    • Description: Three methods with identical structure (double loop ajaxTargets + interceptors). Extracting to a generic private method with @FunctionalInterface reduces bytecode.
    • Location: lines ~245–320
    • Effort: Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    severity: mediumModerate impact; needs attention but not critical.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions