Skip to content

Commit 5dea6c7

Browse files
committed
[#1668] Throw correct exception when onFlush is called
onFlush is not reactive, reactiveOnFlush should be called instead. For this situations, with have a custom exception in the Logger: ``` throw LOG.nonReactiveMethodCall( "reactiveOnFlush" ); ```
1 parent ea6014c commit 5dea6c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveFlushEventListener.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
import org.hibernate.event.spi.FlushEvent;
1414
import org.hibernate.event.spi.FlushEventListener;
1515
import org.hibernate.reactive.event.ReactiveFlushEventListener;
16+
import org.hibernate.reactive.logging.impl.Log;
1617
import org.hibernate.reactive.session.ReactiveSession;
1718
import org.hibernate.stat.spi.StatisticsImplementor;
1819

20+
import static java.lang.invoke.MethodHandles.lookup;
21+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
1922
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;
2023

2124
/**
@@ -24,6 +27,8 @@
2427
public class DefaultReactiveFlushEventListener extends AbstractReactiveFlushingEventListener
2528
implements ReactiveFlushEventListener, FlushEventListener {
2629

30+
private static final Log LOG = make( Log.class, lookup() );
31+
2732
@Override
2833
public CompletionStage<Void> reactiveOnFlush(FlushEvent event) throws HibernateException {
2934
final EventSource source = event.getSession();
@@ -59,6 +64,6 @@ else if ( ((ReactiveSession) source).getReactiveActionQueue().hasAnyQueuedAction
5964

6065
@Override
6166
public void onFlush(FlushEvent event) throws HibernateException {
62-
throw new UnsupportedOperationException();
67+
throw LOG.nonReactiveMethodCall( "reactiveOnFlush" );
6368
}
6469
}

0 commit comments

Comments
 (0)