Improves performance of VaadinService.requestEnd(). (#14218)
Doing two times session.accessSynchronously is unnecessary effort in
multiple aspects:
* The session will be locked twice.
* CurrentInstances are set twice.
* CurrentInstances are restored twice.
* VaadinSession being checked for being the current via
VaadinService.verifyNoOtherSessionLocked(this);
When we leave requestEnd we unset all CurrentInstances. There is no need
to just restore them before doing so.
When we are in requestEnd, VaadinSession is set to "current" by
PushHandler.callWithUi() or VaadinService.handleRequest().
Also, the cleanupSession code does not need any of these thread locals,
so not having them set would also not hurt.
having an extra accessSynchronously call for just setting the duration
does not make a lot of sense. While it somehow wants to make the previous
accessSynchronously call to be counted completely into the duration it
invests an the same time that would have been left out additionally.
VaadinService removeClosedUIs is a cleanup which also locks and sets
CurrentInstances just to figure out that the UI it is checking is not
closing. This change moves that check out of ui.accessSynchronously.
In the end, the resulting code is a tiny bit less robust, however it
eliminates over 50% response time on trivial push request/responses.
Change-Id: If71d1dbbae5d1fd57d3d4e735c592fd263261a81
Optimizes initial sizes of frequently used Collections. (#14223)
There are a few places in frequently used core classes which could
initialize collection classes with the correct (or slightly oversized)
length.
Maps are initialized with 2x the size due to its load factor.
Change-Id: I3aee5a60602937a8550ca5a200ec2a529ff36fe9
Fix findUI throwing NullPointerException when extending Vaadin (#13556)
findUI sometimes threw a NPE when the session wasn't set but the UI ID
was. Doesn't occur in normal use, just when doing custom things with
requestStart/requestEnd or runPendingAccessTasks
Change-Id: Id7733567923fa30dcab4946c43b73200c2a0fac2
Fix race condition that might leave access queue unpurged (#12292)
Cherry-pick of 3a373efe (the original fix) and 2ff71f62 (fixing a
regression) that were marked to not be automatically merged from 7.1 to
master.
Change-Id: Iee1012486906d8c2c46cef94cfcd6d2b399d7a6b
The session might be invalidated before lockSession() acquires the lock.
Check if the session is still valid after locking and ensure
SessionExpiredException is thrown if not.
Change-Id: Iad716332a65b7c198427fce5198f6808140c140c
Make VaadinService.closeInactiveUIs set UI threadlocals (#12186)
Also update javadocs for methods called without UI threadlocals
Also make sure pending access tasks are run for a UI being closed
Change-Id: Ia600207b2d25fc195ee4254da371d420152bf100
Deal correctly with session expired during opening of push connection (#11705)
* Added SessionExpiredHandler which any RequestHandler can implement to customize session expired handling
* The issue can be tested by creating a non-serializable UI (e.g. new Object() in a field) and restarting the server.
Change-Id: I3eb6bc56298e025bcde088af53ea656fb44e897b
Furthermore, the exception that might get thrown from there is passed up
through the call stack until it can be handled in a sensible way.
Change-Id: I4a741b5ad4d9216255932c2328b49e73e92df2f4
Verify CSRF token before accepting new CSRF connection (#11635)
* Can't open push connection during client-side init because CSRF token
is not available at that point. This allows simplifying the
initialization because the push state will not be checked until the
first response has been processed.
* Add helper for checking the CSRF token
Change-Id: I31da1ac669dc9a581cbd66f58c07f10ea4b8b676
* Asynchronous bidirectional communication
* Use Atmosphere as a backend
* Use websockets if available, fallback to HTTP streaming
* Push mode (disabled, manual, automatic)
* Configurable via servlet parameter pushMode
* Disabled: The default; regular AJAX communication
* Manual: Need explicit UI.push() call
* Automatic: push all UIs in session when lock released
* UI.push()
* Push pending state and RPC to client asynchronously
* Must hold session lock when invoking
Change-Id: Idb5978ac81f7ff1e66665df4e3f96e29e4c419d4
Refactored how all requests are handled by VaadinServlet and VaadinPortlet (#11192)
* Handling is now based on a list of RequestHandlers in VaadinService
* Request handling logic has been moved to VaadinService
* Users can customize the list by adding own (service level) request handlers
* For users specific request handlers you can still use the request handlers in VaadinSession
* Deprecated RequestType - all handlers are given the opportunity to handle a request until one of them chooses to handle it. RequestType makes no sense as it does not tell which handler will handle the request.
* Removed serveStaticResource which has never been used
Change-Id: Ia7d088535e46430ca8adf631d3f1dd944b9d51e2
Moved request start/end handling to VaadinService (#11400)
* VaadinService.requestStart/requestEnd is called for all requests, including static resource requests
Change-Id: Ic19f33f069d0b4f4127fdafc7b5c3a2fa1a3b5dc
Changed VaadinSession locking to be based on a session attribute (#8894)
Locking of a VaadinSession is now done in VaadinService using the underlying HTTP session. This enables locking of the VaadinSession even before it has been created.
Change-Id: I815d08d1fb74a1d0905c58b190bb10aa2161a834
Removed CommunicationManager and PortletCommunicationManager
* Moved AbstractCommunicationManager abstract methods
getThemeResourceAsStream and createBootstrapHandler to VaadinService
* Made ACM non-abstract and renamed to LegacyCommunicationManager
* Lifted anonymous inner BootstrapHandler subclasses into named public classes
Change-Id: I31739ce8a506d572e75ca8cd5509be215e01693d