Search.session() does not work with session proxies

Description

Search.session() creates a LazyInitSearchSession that retrieves the actual underlying SearchSession lazily upon first access, and then caches it.

This means that, if you call Search.session on a Session proxy that relies on thread-locals to redirect calls to the actual session (e.g. sessionFactory.getCurrentSession(), or Spring EntityManager proxies), the resulting SearchSession will always delegate to the Session from the first thread. This is problematic for many reasons: thread-safety (a session will be accessed from concurrent threads), search (we'll retrieve entities from an unrelated session), indexing (we'll add indexing operations to the wrong session/transaction), ...

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Sprint

Fix versions

Priority

Created November 14, 2020 at 8:06 AM
Updated November 23, 2020 at 2:06 PM
Resolved November 16, 2020 at 9:49 AM

Flag notifications