AutoFlushEvent#isFlushRequired is always false

Description

DefaultAutoFlushEventListener#onAutoFlush, the method responsible for implementing automatic flushes, goes like this:

The second call to flushIsReallyNeeded inspects an action queue that is either empty, or devoid of any action related to the flush, so it will often (always?) return false.

This is a problem for other implementors of AutoFlushEvent listeners, because we cannot know whether a flush actually occurred or not. In Hibernate Search, it is problematic for in particular (see this comment).

I suspect this bug might cause a few other bugs in ORM, too, because isFlushRequired is used as the return value of org.hibernate.internal.SessionImpl#autoFlushIfRequired, which in turn is used in org.hibernate.internal.SessionImpl#getFilterQueryPlan to handle some edge case. I think this edge case handling code is currently dead code.

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure