Repository: wicket Updated Branches: refs/heads/wicket-atmosphere-tester 2a123aebd -> 6a294f38c
WICKET-5371 IllegalArgumentException: Argument 'page' may not be null. - when sending event from asynchronous process Log a warning and unregister all subscriptions for a page when it is no more in the page stores for any reason Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b26481d5 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b26481d5 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b26481d5 Branch: refs/heads/wicket-atmosphere-tester Commit: b26481d59dc6d38718a5c176a7b921b9d00d6240 Parents: 18f269e Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Thu Aug 14 15:21:18 2014 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Thu Aug 14 15:21:18 2014 +0200 ---------------------------------------------------------------------- .../atmosphere/AtmosphereRequestHandler.java | 18 +++++++++++++++--- .../org/apache/wicket/atmosphere/EventBus.java | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/b26481d5/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereRequestHandler.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereRequestHandler.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereRequestHandler.java index 3ba143d..f19e7e0 100644 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereRequestHandler.java +++ b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereRequestHandler.java @@ -20,6 +20,7 @@ import java.util.Iterator; import org.apache.wicket.Component; import org.apache.wicket.Page; +import org.apache.wicket.Session; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.Behavior; import org.apache.wicket.protocol.http.WebApplication; @@ -71,9 +72,20 @@ public class AtmosphereRequestHandler implements IRequestHandler public void respond(IRequestCycle requestCycle) { WebApplication application = WebApplication.get(); - Page page = (Page)application.getMapperContext().getPageInstance(pageKey.getPageId()); - AjaxRequestTarget target = application.newAjaxRequestTarget(page); - executeHandlers(target, page); + Integer pageId = pageKey.getPageId(); + Page page = (Page) Session.get().getPageManager().getPage(pageId); + if (page != null) + { + AjaxRequestTarget target = application.newAjaxRequestTarget(page); + executeHandlers(target, page); + } + else + { + LOGGER.warn("Could not find a page with id '{}' for session with id '{}' in the page stores. It will be unregistered", + pageId, pageKey.getSessionId()); + EventBus.get(application).unregister(pageKey); + + } } private void executeHandlers(AjaxRequestTarget target, Page page) http://git-wip-us.apache.org/repos/asf/wicket/blob/b26481d5/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/EventBus.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/EventBus.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/EventBus.java index 80837b8..b085027 100644 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/EventBus.java +++ b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/EventBus.java @@ -274,6 +274,22 @@ public class EventBus implements UnboundListener } /** + * Unregisters all {@link EventSubscription}s for the given pageKey. + * + * @param pageKey + * The key with the page id and session id + */ + public synchronized void unregister(PageKey pageKey) + { + if (log.isDebugEnabled()) + { + log.debug("unregistering all subscriptions for page {} for session {}", + pageKey.getPageId(), pageKey.getSessionId()); + } + subscriptions.removeAll(pageKey); + } + + /** * Unregisters all {@link EventSubscription}s for the given component, including the * subscriptions for its behaviors. *
