Repository navigation
Conversation
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
Contributor
Author
|
Closing at @papegaaij's request in #1998: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1998 to
wicket-10.x, for GitHub issue #1653.ListenerLogDatalooks the listener's component up only when the provider has it without side effects (newIPageAndComponentProvider#hasComponent()), so collecting log data inListenerRequestHandler.detach()no longer creates the page or runsonInitialize(),onConfigure()oronBeforeRender()after the response has been written.hasComponent()is@since 10.13.0, the first release that carries it.The only API change is a default method added to an interface, binary-compatible; japicmp passes against 10.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:
ListenerLogDataTestpasses.mvn clean verify -Pjs-testis green, japicmp included.This goes in after #1998. If #1998 changes in review, this branch gets the same change.