Skip to content

Collect listener log data without running page lifecycle callbacks (11.x) - #2003

Closed
reiern70 wants to merge 2 commits into
wicket-11.xfrom
listener-log-data-1653-11.x
Closed

reiern70 wants to merge 2 commits into
wicket-11.xfrom
listener-log-data-1653-11.x

Conversation

@reiern70

Copy link
Copy Markdown
Contributor

Backport of #1998 to wicket-11.x, for GitHub issue #1653.

The only API change is a default method added to an interface, binary-compatible; japicmp passes against 11.0.0. Log entries lack the component class, the behavior class and the submitting component when the component was not resolved during the request.

Verified on this branch:

  • ListenerLogDataTest passes.
  • mvn clean verify -Pjs-test is green, japicmp included.

This goes in after #1998. If #1998 changes in review, this branch gets the same change.

ListenerRequestHandler builds its ListenerLogData in detach(), after
the response has been written, whether or not a request logger is
enabled. ListenerLogData asked the provider for the component with
getComponent(), up to three times. When a stateless page lacks the
component, PageAndComponentProvider.getComponent() initializes the page
and prepares it for rendering, so that a component added in a lifecycle
callback can still be found; when the provider holds no page yet, for
instance because the page constructor threw, it creates one. So
collecting log data ran the page constructor, onInitialize(),
onConfigure() and onBeforeRender() during detach, once per lookup.
Whatever those callbacks touch then happens too late: in the reported
application onConfigure() resolved a session scoped CDI bean, and the
container created an HTTP session after the response had been
committed and could not send its cookie.

Log data has to describe the request, not take part in it.
IPageAndComponentProvider gets a default method hasComponent(): whether
getComponent() can return the component without creating the page or
running its lifecycle callbacks. PageAndComponentProvider answers true
when it has resolved the component already, or when the page instance
it already has contains a component at the path. ListenerLogData looks
the component up once, and only when the provider has it; otherwise the
component class, the behavior class and the submitting component stay
null, while the component path and the page data are collected as
before.

Building the log data only while a request logger is enabled would
leave the bug in place for every application that logs requests, and
getLogData() is public, so listeners may read it with the logger off.
Looking the component up on the page alone, with page.get(path), would
lose components the provider resolved for the listener and the request
then removed from the page, such as a delete link in a repeater. Asking
the provider keeps those, and every case that was cheap and safe before.

Resolving the component while the request is processed is unchanged:
ListenerRequestHandler.respond() still calls getComponent(), which still
runs the lifecycle callbacks of a stateless page to find a component
added in one of them.

An application that relied on the old behaviour sees log entries
without componentClass, behaviorClass and the submitting component when
the listener's component was not resolved during the request, where the
lookup in detach could find it by running the page's lifecycle
callbacks once more; those callbacks no longer run during detach.
Implementations of IPageAndComponentProvider other than
PageAndComponentProvider must override hasComponent() to have their
component in the log data.

GitHub issue #1653
The method is backported to wicket-10.x and wicket-11.x, so 10.13.0 is
the first release that carries it, not 12.0.0.

GitHub issue #1653
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 62.71%. Comparing base (6014597) to head (7937a40).

Additional details and impacted files
@@              Coverage Diff               @@
##             wicket-11.x    #2003   +/-   ##
==============================================
  Coverage          62.71%   62.71%           
- Complexity         11510    11521   +11     
==============================================
  Files               1254     1255    +1     
  Lines              48665    48668    +3     
  Branches            6845     6846    +1     
==============================================
+ Hits               30519    30524    +5     
+ Misses             15471    15468    -3     
- Partials            2675     2676    +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@reiern70

Copy link
Copy Markdown
Contributor Author

Closing at @papegaaij's request in #1998: hasComponent() is now abstract, and adding an abstract method to a public interface is a 12.0.0 change, so the fix for #1653 doesn't go to the maintenance lines.

@reiern70 reiern70 closed this Nov 24, 2026
@reiern70
reiern70 deleted the listener-log-data-1653-11.x branch November 24, 2026 16:29
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